void CopyFileToBackup(VolumeSnapshotFile file) { try { if (!mOperation.CanContinue) { return; } file.Revision = file.Snapshot.Revision; mArchive.StoreFile(file.Snapshot.Revision, file.RelativePath, mSource.GetOnDiskPath(file.RelativePath), new ArchiveFileDelegate(Backup_ArchiveStoreFile), file); ulong runningSize = mFilesTotalSizeRunning + file.FileSize; if (runningSize > mFilesTotalSize) { runningSize = mFilesTotalSize; } if (Progress != null) { Progress(mFileRunningCount + 1, mFileTotalCount, runningSize, mFilesTotalSize); } } catch (System.Exception e) { mOperation.Cancel(false); mComparator.Cancel(); FileSync.__LogError(this, "Copy file failed '" + file.RelativePath + "'", e); } mFileRunningCount++; mFilesTotalSizeRunning += file.FileSize; }
public void OnFileTheSame(VolumeSnapshotFile oldFile, VolumeSnapshotFile newFile) { mFilesTheSame++; if (mInvokeCallbacks) { if (FileTheSame != null) { FileTheSame(oldFile, newFile); } } }
public override bool Equals(object obj) { if (obj is VolumeSnapshotFile) { VolumeSnapshotFile rhs = (VolumeSnapshotFile)obj; return(string.Compare(rhs.mFileName, this.mFileName, true) == 0); } else { return(false); } }
void Restore_ArchiveStoreFile(ulong fileRunningBytes, ulong fileTotalSize, object userData) { VolumeSnapshotFile file = (VolumeSnapshotFile)userData; ulong runningSize = mFilesTotalSizeRunning + fileRunningBytes; if (runningSize > mFilesTotalSize) { runningSize = mFilesTotalSize; } if (Progress != null) { Progress(mFileRunningCount, mFileTotalCount, runningSize, mFilesTotalSize); } }
public void OnFileChanged(VolumeSnapshotFile oldFile, VolumeSnapshotFile newFile) { mFilesChanged++; mFileCount++; mTotalFileSize += newFile.FileSize; mIsModified = true; if (mInvokeCallbacks) { if (FileChanged != null) { FileChanged(oldFile, newFile); } } }
public void OnFileCreated(VolumeSnapshotFile file) { mFilesCreated++; mFileCount++; mTotalFileSize += file.FileSize; mIsModified = true; if (mInvokeCallbacks) { if (FileCreated != null) { FileCreated(null, file); } } }
private VolumeSnapshotDirectory(VolumeSnapshot snapshot, XmlNode parentNode) { mSnapshot = snapshot; mName = PWLib.XmlHelp.DirtyString(PWLib.XmlHelp.GetAttribute(parentNode, VolumeSnapshotXml.XmlNameElement, "")); mRelativePath = PWLib.XmlHelp.DirtyString(PWLib.XmlHelp.GetAttribute(parentNode, VolumeSnapshotXml.XmlRelativePathElement, "")); mRevision = VolumeSnapshotRevision.Create(PWLib.XmlHelp.GetAttribute(parentNode, VolumeSnapshotXml.XmlRevisionElement, "")); long ticks; if (long.TryParse(PWLib.XmlHelp.GetAttribute(parentNode, VolumeSnapshotXml.XmlLastModifiedElement, "0"), out ticks)) { mLastModified = new DateTime(ticks); } foreach (XmlNode childNode in parentNode.ChildNodes) { string lowerName = childNode.Name.ToLower(); if (lowerName == VolumeSnapshotXml.XmlDirectoryElement) // Sub directories { try { VolumeSnapshotDirectory subDirEntry = new VolumeSnapshotDirectory(mSnapshot, childNode); mDirectories.Add(subDirEntry); } catch (System.Exception e) { FileSync.__LogError(this, "VolumeSnapshotDirectory.BuildFromXml failed in directory '" + mName + "' '" + mRelativePath + "'", e); } } else if (lowerName == VolumeSnapshotXml.XmlFileElement) // Files { try { VolumeSnapshotFile fileEntry = VolumeSnapshotFile.BuildFromXml(mSnapshot, childNode); mFiles.Add(fileEntry); } catch (System.Exception e) { FileSync.__LogError(this, "VolumeSnapshotDirectory.BuildFromXml failed in directory on a file '" + mName + "' '" + mRelativePath + "'", e); } } } }
private VolumeSnapshotDirectory(VolumeSnapshot snapshot, VolumeSource source, string relativePath) { mSnapshot = snapshot; mRelativePath = relativePath; mName = mRelativePath.Length <= 1 ? "" : PWLib.Platform.Windows.Path.GetLeafName(relativePath); mLastModified = source.GetLastWriteTimeUtc(relativePath); // PWLib.Platform.Windows.Directory.GetLastWriteTimeUtc( rootDir ); foreach (string filename in source.GetRelativePathFiles(relativePath) /* PWLib.Platform.Windows.Directory.GetFiles( rootDir ) */) { try { VolumeSnapshotFile fileEntry = VolumeSnapshotFile.BuildFromSource(mSnapshot, source, filename); mFiles.Add(fileEntry); } catch (System.Exception e) { FileSync.__LogError(this, "VolumeSnapshotDirectory.BuildFromFileSystem failed on file '" + filename + "'", e); } } foreach (string subDir in source.GetRelativePathDirectories(relativePath)) { try { if (!IsIgnoredDirectoryName(PWLib.Platform.Windows.Path.GetLeafName(subDir))) { VolumeSnapshotDirectory subDirEntry = new VolumeSnapshotDirectory(mSnapshot, source, subDir); mDirectories.Add(subDirEntry); } } catch (System.Exception e) { FileSync.__LogError(this, "VolumeSnapshotDirectory.BuildFromFileSystem failed on directory '" + subDir + "'", e); } } }
public void OnFileChanged( VolumeSnapshotFile oldFile, VolumeSnapshotFile newFile ) { mFilesChanged++; mFileCount++; mTotalFileSize += newFile.FileSize; mIsModified = true; if ( mInvokeCallbacks ) { if ( FileChanged != null ) FileChanged( oldFile, newFile ); } }
void mComparator_FileTheSame( VolumeSnapshotFile oldFile, VolumeSnapshotFile newFile ) { newFile.Revision = oldFile.Revision; }
void mComparator_FileCreated( VolumeSnapshotFile oldFile, VolumeSnapshotFile newFile ) { CopyFileToBackup( newFile ); }
void CopyFileToBackup( VolumeSnapshotFile file ) { try { if ( !mOperation.CanContinue ) return; file.Revision = file.Snapshot.Revision; mArchive.StoreFile( file.Snapshot.Revision, file.RelativePath, mSource.GetOnDiskPath( file.RelativePath ), new ArchiveFileDelegate( Backup_ArchiveStoreFile ), file ); ulong runningSize = mFilesTotalSizeRunning + file.FileSize; if ( runningSize > mFilesTotalSize ) runningSize = mFilesTotalSize; if ( Progress != null ) Progress( mFileRunningCount + 1, mFileTotalCount, runningSize, mFilesTotalSize ); } catch ( System.Exception e ) { mOperation.Cancel( false ); mComparator.Cancel(); FileSync.__LogError( this, "Copy file failed '" + file.RelativePath + "'", e ); } mFileRunningCount++; mFilesTotalSizeRunning += file.FileSize; }
void mComparator_FileTheSame(VolumeSnapshotFile oldFile, VolumeSnapshotFile newFile) { newFile.Revision = oldFile.Revision; }
void mComparator_FileCreated(VolumeSnapshotFile oldFile, VolumeSnapshotFile newFile) { CopyFileToBackup(newFile); }
public void OnFileRemoved( VolumeSnapshotFile oldFile ) { mFilesRemoved++; mIsModified = true; }
public void OnFileRemoved(VolumeSnapshotFile oldFile) { mFilesRemoved++; mIsModified = true; }
public void OnFileCreated( VolumeSnapshotFile file ) { mFilesCreated++; mFileCount++; mTotalFileSize += file.FileSize; mIsModified = true; if ( mInvokeCallbacks ) { if ( FileCreated != null ) FileCreated( null, file ); } }
public void OnFileTheSame( VolumeSnapshotFile oldFile, VolumeSnapshotFile newFile ) { mFilesTheSame++; if ( mInvokeCallbacks ) { if ( FileTheSame != null ) FileTheSame( oldFile, newFile ); } }
private bool ProcessDirectory(VolumeSnapshotDirectory oldDb, VolumeSnapshotDirectory newDb) { // check for new/changed files foreach (VolumeSnapshotFile newFile in newDb.Files) { // see if the file exists in the rhs snapshot and if it has changed VolumeSnapshotFile oldFile = oldDb.FindFile(newFile.FileName); if (oldFile == null) { // File has been created mStats.OnFileCreated(newFile); } else { // File exists in both snapshots, check last modified date if (oldFile.LastModified.Ticks != newFile.LastModified.Ticks) { // file has been modified mStats.OnFileChanged(oldFile, newFile); } else { // file the same mStats.OnFileTheSame(oldFile, newFile); } } if (!mOperation.CanContinue) { return(mStats.IsModified); } } // check for deleted files foreach (VolumeSnapshotFile oldFile in oldDb.Files) { VolumeSnapshotFile newFile = newDb.FindFile(oldFile.FileName); if (newFile == null) { mStats.OnFileRemoved(oldFile); } if (!mOperation.CanContinue) { return(mStats.IsModified); } } // check for deleted directories foreach (VolumeSnapshotDirectory oldDir in oldDb.Directories) { VolumeSnapshotDirectory newDir = newDb.FindDirectory(oldDir.Name); if (newDir == null) { mStats.OnDirectoryRemoved(oldDir); } if (!mOperation.CanContinue) { return(mStats.IsModified); } } // check for new directories foreach (VolumeSnapshotDirectory newDir in newDb.Directories) { VolumeSnapshotDirectory oldDir = oldDb.FindDirectory(newDir.Name); if (oldDir == null) { // Directory has been created mStats.OnDirectoryCreated(newDir); } else { mStats.OnDirectoryTheSame(oldDir, newDir); ProcessDirectory(oldDir, newDir); } if (!mOperation.CanContinue) { return(mStats.IsModified); } } return(mStats.IsModified); }