locked
get info of sync files RRS feed

  • Question

  •  if some files have been sinchronized, how do i replace the old ones, taking a file size parameter?, because i want to sync but if in the selected folder exists files with the same name i want to replace them with the bigger files?

    Exists some intermediate process that allow me to do that?

    Wednesday, May 12, 2010 4:43 AM

Answers

  • Hi,

    You are using a sample built with the File Sync provider (http://msdn.microsoft.com/en-us/library/bb902860(v=SQL.105).aspx). As I mentioned in my previous email, File Sync Provider has built-in policy for change detection (File size, file attribute, last modification time, and optional file stream hash value). You cannot replace its change detection with your own rules such as only detect files that become larger. If you really want to do it with File Sync provider, you need to register ApplyingChange event and compare the incoming item file size with the local same name file. if the incoming file size is bigger, you will let the provider to continue applying this change. Otherwise, you need to skip the change: ApplyingChangeEventArgs.SkipChange=true. The drawback of this approach is that the same change will be sent again and again in the following syncs even you don't make any changes on them. If you have many such kind of changes, the performance of your sync app will be bad.

    Another option is to write your own sync provider based on KnowledgeSyncProvider (http://msdn.microsoft.com/en-us/library/bb902826(v=SQL.105).aspx) or simple provider interface (http://msdn.microsoft.com/en-us/library/dd937537(v=SQL.105).aspx). You can control the change detection rules in these custom providers. Several samples can be found in http://code.msdn.microsoft.com/sync.

    Thanks,
    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    Thursday, May 13, 2010 4:56 AM

All replies

  • a change in file size will be detected as a change by the file sync providers. if you want to compare file sizes to determine which copy to retain, you can do the checking on the ApplyingChange event.
    Wednesday, May 12, 2010 12:17 PM
  • Hi,

    Are you writting a Knowledge sync provider for file sync, or using the File Sync Provider built by Microsoft Sync Framework? If you are writting a knowledge sync provider for your scenario, you have different ways to achieve your purpose. For example, if you only want to sync new changes when file becomes bigger, you can only update your sync metadata when the local file is bigger than before. If you want to always sync newer files, you can use last modification time to detect change. JuneT's proposal is an option as well, but it means change will always be sent to destination side, and your code decide if you want to apply it or not in the ApplyingChange event.

    If you use the File Sync Provider built by Microsoft Sync Framework, it uses last modification time, file attributes and file size to detect a new change, you can enable filestream hash value for change detection as well. If you want sync new changes instead of just bigger files, it will be the most simple option for you.

    Thanks,
    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    Wednesday, May 12, 2010 6:14 PM
  • Im using the microsoft sync framework example and i want to know how can i modified the example to replace just the bigger files?  because when i sync the files the agent.Synchronize() doesnt evaluate file per file?

    FileStream stream = new FileStream();

                stream.Length;

                options = FileSyncOptions.CompareFileStreams | FileSyncOptions.ExplicitDetectChanges | FileSyncOptions.RecyclePreviousFileOnUpdates;

     

    or where can i add the stream.Lenght in the code???

    I'm student and I'm new at this, so anything will be helpful!!

    Thanks!!!

    Daniel.

     

    Thursday, May 13, 2010 2:12 AM
  • Hi,

    You are using a sample built with the File Sync provider (http://msdn.microsoft.com/en-us/library/bb902860(v=SQL.105).aspx). As I mentioned in my previous email, File Sync Provider has built-in policy for change detection (File size, file attribute, last modification time, and optional file stream hash value). You cannot replace its change detection with your own rules such as only detect files that become larger. If you really want to do it with File Sync provider, you need to register ApplyingChange event and compare the incoming item file size with the local same name file. if the incoming file size is bigger, you will let the provider to continue applying this change. Otherwise, you need to skip the change: ApplyingChangeEventArgs.SkipChange=true. The drawback of this approach is that the same change will be sent again and again in the following syncs even you don't make any changes on them. If you have many such kind of changes, the performance of your sync app will be bad.

    Another option is to write your own sync provider based on KnowledgeSyncProvider (http://msdn.microsoft.com/en-us/library/bb902826(v=SQL.105).aspx) or simple provider interface (http://msdn.microsoft.com/en-us/library/dd937537(v=SQL.105).aspx). You can control the change detection rules in these custom providers. Several samples can be found in http://code.msdn.microsoft.com/sync.

    Thanks,
    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    Thursday, May 13, 2010 4:56 AM