locked
DetectChanges does not reinspect destination folder correctly RRS feed

  • Question

  • I have Folder1 and Folder2.  I want to backup the contents of Folder1 to Folder2 - effectively Folder2 is an image of Folder1, which means I want to do the following:

    1) Copy any files and folders within Folder1 to Folder2
    2) Update any files in Folder2 that are different to those in Folder1
    3) Delete any files and folders in Folder2 which no longer exist in Folder1

    All sounds straight forward but SyncFramework will not do it.

    Consider this example:

    If the Sync has been run once, everything is fine.  Metadata is stored for both Folder1 and Folder2.  If the entire contents of Folder2 is deleted (manually delete it as a test), and the Sync is run again, it should detect that the files are missing and copy the contents of Folder1 across again right?  This does not happen!  Folder2 remains empty after the Sync although the SyncFramework performs the Sync tasks. 

    It appears that when DetectChanges is called, it does not inspect Folder2, all it does is check the metadata for Folder2 against the contents of Folder1.  In my example above, the metadata has not changed so no Sync action is performed and Folder2 remains empty.

    If I manually delete the metadata for Folder2, and then run Sync again, the files are correctly copied across again because presumably if it can't find metadata for a folder, it inspects the folder again.

    You could argue that the user should not delete files in the destination folder (Folder2).  Surely the Sync framework should not rely on what the user does or does not do, it should be intelligent.

    Consider also this example:

    I want to give the user the option of excluding files and folders if they wish. If the user configures the file and folder exclusions and then the Sync is done the first time, all is well - the excluded files and folders do not appear in Folder2.

    If the user changes the exclusions list (for example, user decides that no .txt files should be copied across) then I would expect that next time Sync was run, the SyncFramework would notice that there were .txt files in Folder2 and delete them because as far as it should be concerned, no .txt files exist in Folder1 (because they are excluded, it should ignore them).

    This does not work - the .txt files in Folder2 are not removed.
    Even if I manually delete the metadata, the .txt files are not removed.

    Am I wasting my time using the SyncFramework?

    • Moved by Max Wang_1983 Thursday, April 21, 2011 5:40 PM forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    Monday, February 9, 2009 2:08 PM

Answers

  • Hello,

    I am a little bit confused with your description. In a folder pair, you manually delete Folder2, then why would you expect the next sync will copy files from folder 1? If you delete files
    after you sync'd, then the deletes are considered newer change, so even if you sync from folder 1 to folder 2, the files will not be restored on folder 2. Sync concept is different from
    simple diffing of two folder pairs.

    The idea is, the user has decided to delete the files on folder 2 even after seeing that it had the latest version of the file, so the user decided to delete those files, and that is

    considered the final change on those files. There are ways to restore the files however. Nevertheless, I suggest you to take a look at example / description of synchronization

    concept http://msdn.microsoft.com/en-us/sync/bb821992.aspx#sync 

    Hope this helps,

    Patrick




    Monday, February 16, 2009 5:32 PM

All replies

  • Hello,

    I am a little bit confused with your description. In a folder pair, you manually delete Folder2, then why would you expect the next sync will copy files from folder 1? If you delete files
    after you sync'd, then the deletes are considered newer change, so even if you sync from folder 1 to folder 2, the files will not be restored on folder 2. Sync concept is different from
    simple diffing of two folder pairs.

    The idea is, the user has decided to delete the files on folder 2 even after seeing that it had the latest version of the file, so the user decided to delete those files, and that is

    considered the final change on those files. There are ways to restore the files however. Nevertheless, I suggest you to take a look at example / description of synchronization

    concept http://msdn.microsoft.com/en-us/sync/bb821992.aspx#sync 

    Hope this helps,

    Patrick




    Monday, February 16, 2009 5:32 PM
  • Hi,

    To be fair to the orginal poster I has assumed the same thought process.  I've just started to look at the framework and I too had assumed this kind of behaviour until I found this thread.

    How would you go about getting this sort of behaviour from the framework?

    Regards,

    jammer
    Sunday, March 15, 2009 4:42 PM
  • Hello,

    I have the same problem like the original poster. I would like to synchronize the content from Folder A to Folder B (Upload) and always restore the state from Folder A in Folder B. Folder B should act like a mirror of Folder A.

    You have mentioned that there are ways to trigger this behavior, e.g. restoring files which where deleted on the destination folder. I haven't found a convienient way (using the FileSyncProviders and the SyncOrchestrator) to get this behaviour so far.

    Please tell me if and how the SyncFramework can be used to get this behaviour.  

    Ray
    Wednesday, March 18, 2009 11:59 AM
  • Hi Ray,

    I have resorted to deleting the metadata files for both replicas and basically performing a new one way sync from A to B ...

    That was the only way I have found to reliably get this behaviour working.  Seems like a hatchet job to get the sync framework to do something it should be capable of out of the box imho ...

    Regards,

    jammer
    Thursday, March 19, 2009 6:46 PM