/// <summary> /// Process a detected deletion. /// </summary> /// <param name="remoteFolder">Remote folder.</param> /// <param name="localFolder">Local folder.</param> /// <param name="pathname">Pathname.</param> /// <returns>Whether the delete has now been synchronized, so that no further action is needed</returns> private bool WatcherSyncDelete(string remoteFolder, string localFolder, string pathname, Grace grace) { SleepWhileSuspended(); // In many programs (like Microsoft Word), deletion is often just a save: // 1. Save data to temporary file ~wrdxxxx.tmp // 2. Delete Example.doc // 3. Rename ~wrdxxxx.tmp to Example.doc // See https://support.microsoft.com/en-us/kb/211632 // So, upon deletion, wait a bit for any save operation to hopefully finalize, then sync. // This is not 100% foolproof, as saving can last for more than the grace time, but probably // the best we can do without mind-reading third-party programs. grace.WaitGraceTime(); try { if (Utils.IsMetadataFile(pathname)) { // Nothing to do return(true); } SyncItem item = database.GetSyncItemFromLocalPath(pathname); if (item == null) { // The item must be in the database return(false); } ICmisObject cmisObject = session.GetObjectByPath(item.RemotePath); if (cmisObject == null) { // the object does not exist on the server so nothing to do return(true); } cmisObject.Delete(true); // Folder or File database.RemoveFolder(item); database.RemoveFile(item); // Remove metadata if exists if (File.Exists(pathname + ".metadata")) { File.Delete(pathname + ".metadata"); database.RemoveMetadataFile(item); } return(true); } catch (Exception e) { ProcessRecoverableException("Could Not process Watch Sync Delete : ", e); return(false); } }
/// <summary> /// Process a detected deletion. /// </summary> /// <param name="remoteFolder">Remote folder.</param> /// <param name="localFolder">Local folder.</param> /// <param name="pathname">Pathname.</param> /// <returns>Whether the delete has now been synchronized, so that no further action is needed</returns> private bool WatcherSyncDelete(string remoteFolder, string localFolder, string pathname, Grace grace) { SleepWhileSuspended(); // In many programs (like Microsoft Word), deletion is often just a save: // 1. Save data to temporary file ~wrdxxxx.tmp // 2. Delete Example.doc // 3. Rename ~wrdxxxx.tmp to Example.doc // See https://support.microsoft.com/en-us/kb/211632 // So, upon deletion, wait a bit for any save operation to hopefully finalize, then sync. // This is not 100% foolproof, as saving can last for more than the grace time, but probably // the best we can do without mind-reading third-party programs. grace.WaitGraceTime(); return(false); // Perform a sync. }
/// <summary> /// Process a detected deletion. /// </summary> /// <param name="remoteFolder">Remote folder.</param> /// <param name="localFolder">Local folder.</param> /// <param name="pathname">Pathname.</param> /// <returns>Whether the delete has now been synchronized, so that no further action is needed</returns> private bool WatcherSyncDelete(string remoteFolder, string localFolder, string pathname, Grace grace) { SleepWhileSuspended(); // In many programs (like Microsoft Word), deletion is often just a save: // 1. Save data to temporary file ~wrdxxxx.tmp // 2. Delete Example.doc // 3. Rename ~wrdxxxx.tmp to Example.doc // See https://support.microsoft.com/en-us/kb/211632 // So, upon deletion, wait a bit for any save operation to hopefully finalize, then sync. // This is not 100% foolproof, as saving can last for more than the grace time, but probably // the best we can do without mind-reading third-party programs. grace.WaitGraceTime(); return false; // Perform a sync. }