/// <summary> /// Performs cleanup of historic data which is not used /// </summary> public void Cleanup() { lock (cleanupSync) { // Clean expired workspaces trackingWorkspaceStateProvider.Cleanup(); // Determine which snapshots are used var usedSnapshots = trackingWorkspaceStateProvider.UsedSnapshotIds(); // Ensure that last is always used var lastSnapshot = snapshotsService.GetLatestSnapshotId(); if (!usedSnapshots.Contains(lastSnapshot)) { usedSnapshots.Add(lastSnapshot); } // Determine which snapshots are not used, remove them from shapshots list var unusedSnapshots = snapshotsService.RemoveUnusedSnapshots(usedSnapshots); // Process removed snapshots foreach (var snapshotId in unusedSnapshots) { // Garbage collect nodes which are not used var collectedNodesEnumerator = collectedNodesProvider.GetEdges(snapshotId); if (collectedNodesEnumerator != null) { using (collectedNodesEnumerator) { while (collectedNodesEnumerator.MoveNext()) { provider.Remove(collectedNodesEnumerator.Current.ToNodeId); } } } // Remove change set history information changeSetProvider.RemoveChangeSet(snapshotId); // Remove information about collected nodes in the snapshot collectedNodesProvider.Cleanup(snapshotId); // Remove the snapshot node provider.Remove(snapshotId); } } }