void MergeSnapshotRevisions(VolumeSnapshotDatabase database, VolumeSource source, BaseArchive archive, int numRevisionsToRemove) { try { mDatabase = database; mArchive = archive; mBusy = true; List <VolumeSnapshotRevision> revisionHistory = database.GetRevisionHistory(); if (numRevisionsToRemove == revisionHistory.Count) { // Need to remove all old revisions, delete everything FileSync.__Log(this, "Merge deleting all revisions"); database.DeleteAllRevisions(); } else { // now we know how many revisions to remove, need to rebuild the new first revision. VolumeSnapshotRevision currentRevision = revisionHistory[numRevisionsToRemove]; VolumeSnapshot currentSnapshot = database.LoadSnapshotRevision(source, currentRevision); FileSync.__Log(this, "Merge is turning revision [" + currentRevision.ToString() + "] into baseline"); TurnSnapshotIntoBaseline(currentSnapshot); // Now go through all existing snapshot .xml files and change any files referencing // a snapshot that has been removed and change it to the current snapshot revision. for (int revisionNum = numRevisionsToRemove + 1; revisionNum < revisionHistory.Count; ++revisionNum) { VolumeSnapshotRevision incrementalRevision = revisionHistory[revisionNum]; VolumeSnapshot incrementalSnapshot = database.LoadSnapshotRevision(source, incrementalRevision); FileSync.__Log(this, "Merge is reflecting revision [" + incrementalRevision.ToString() + "] into new baseline [" + currentRevision.ToString() + "]"); UpdateSnapshotToReflectBaselineRevision(incrementalSnapshot, currentRevision); } // delete old revision data for (int revisionNum = 0; revisionNum < numRevisionsToRemove; ++revisionNum) { VolumeSnapshotRevision revisionToDelete = revisionHistory[revisionNum]; FileSync.__Log(this, "Merge is deleting revision [" + revisionToDelete.ToString() + "]"); database.DeleteSnapshotRevision(revisionToDelete); } } } catch (System.Exception ex) { FileSync.__LogError(this, "Volume.CheckForExpiredSnapshotRevisions", ex); } finally { mBusy = false; } }
public void DeleteAllRevisions() { mDatabase.DeleteAllRevisions(); mArchive.DeleteAllRevisions(); }
void MergeSnapshotRevisions( VolumeSnapshotDatabase database, VolumeSource source, BaseArchive archive, int numRevisionsToRemove ) { try { mDatabase = database; mArchive = archive; mBusy = true; List<VolumeSnapshotRevision> revisionHistory = database.GetRevisionHistory(); if ( numRevisionsToRemove == revisionHistory.Count ) { // Need to remove all old revisions, delete everything FileSync.__Log( this, "Merge deleting all revisions" ); database.DeleteAllRevisions(); } else { // now we know how many revisions to remove, need to rebuild the new first revision. VolumeSnapshotRevision currentRevision = revisionHistory[ numRevisionsToRemove ]; VolumeSnapshot currentSnapshot = database.LoadSnapshotRevision( source, currentRevision ); FileSync.__Log( this, "Merge is turning revision [" + currentRevision.ToString() + "] into baseline" ); TurnSnapshotIntoBaseline( currentSnapshot ); // Now go through all existing snapshot .xml files and change any files referencing // a snapshot that has been removed and change it to the current snapshot revision. for ( int revisionNum = numRevisionsToRemove + 1; revisionNum < revisionHistory.Count; ++revisionNum ) { VolumeSnapshotRevision incrementalRevision = revisionHistory[ revisionNum ]; VolumeSnapshot incrementalSnapshot = database.LoadSnapshotRevision( source, incrementalRevision ); FileSync.__Log( this, "Merge is reflecting revision [" + incrementalRevision.ToString() + "] into new baseline [" + currentRevision.ToString() + "]" ); UpdateSnapshotToReflectBaselineRevision( incrementalSnapshot, currentRevision ); } // delete old revision data for ( int revisionNum = 0; revisionNum < numRevisionsToRemove; ++revisionNum ) { VolumeSnapshotRevision revisionToDelete = revisionHistory[ revisionNum ]; FileSync.__Log( this, "Merge is deleting revision [" + revisionToDelete.ToString() + "]" ); database.DeleteSnapshotRevision( revisionToDelete ); } } } catch ( System.Exception ex ) { FileSync.__LogError( this, "Volume.CheckForExpiredSnapshotRevisions", ex ); } finally { mBusy = false; } }