Asked by:
Metadata already in use error in microsoft sync frame work

Question
-
Metadata already in use error in microsoft sync frame workSunday, September 18, 2011 11:01 AM
All replies
-
which providers are you using? what are you trying to sync?Tuesday, September 20, 2011 2:58 AM
-
trying to syncronize files between two folder using microsoft sync frame work
below code is i am using. using timer to syncronise files at particular interval of time.
class
FileSyncProviderSample
{
{
arg[0] =
@"C:\Projects\TestFolder\F1";arg[1] =
@"C:\Projects\TestFolder\F2";!
Directory.Exists(arg[0]) || !Directory.Exists(arg[1])){
}
System.Timers.
Timer objTimer;{
objTimer =
new System.Timers.Timer(1000);objTimer.Elapsed +=
new System.Timers.ElapsedEventHandler(objTimer_Elapsed);objTimer.Interval = 10000;
objTimer.Enabled =
true;}
{
}
}
{
FileSyncOptions
.RecyclePreviousFileOnUpdates |
FileSyncOptions
.RecycleConflictLoserFiles;
filter.FileNameExcludes.Add(
"*.lnk"); // Exclude all *.lnk filesfilter.FileNameExcludes.Add(
"filesync.metadata");DetectChangesOnFileSystemReplica(
replica1RootPath, filter, options);
DetectChangesOnFileSystemReplica(
replica2RootPath, filter, options);
SyncFileSystemReplicasOneWay(replica1RootPath, replica2RootPath,
null, options);SyncFileSystemReplicasOneWay(replica2RootPath, replica1RootPath,
null, options);}
{
WatchDirectory(
@"C:\Projects\TestFolder\F1", @"C:\Projects\TestFolder\F2");}
{
{
provider =
new FileSyncProvider( new System.Guid(),replicaRootPath, filter, options);provider.DetectChanges();
}
{
}
{
provider.Dispose();
}
}
{
{
destinationProvider =
new FileSyncProvider(destinationReplicaRootPath, filter, options);
destinationProvider.AppliedChange +=
destinationProvider.SkippedChange +=
agent.LocalProvider = sourceProvider;
agent.RemoteProvider = destinationProvider;
agent.Direction =
SyncDirectionOrder.Upload;// Upload; // Sync source to destinationdestinationProvider.RootDirectoryPath);
agent.Synchronize();
}
{
}
{
}
}
{
{
}
}
{
+
" for " + (!string.IsNullOrEmpty(args.CurrentFilePath) ?args.CurrentFilePath : args.NewFilePath) +
" due to error");}
}
Wednesday, September 28, 2011 5:15 AM -
check that you're not having two concurrent syncs on going. specifically, if your timer fires, check that it doesnt fire anew while the sync from the first timer event is not yet complete.Wednesday, September 28, 2011 8:15 AM
-
i am checking with only one or two files .this error is occur only if any file is created on the folder. if there is no change in folders , no error.
Wednesday, September 28, 2011 12:49 PM -
do a quick check without a timer or disabling the timer while a sync is ongoing. that should give you an idea.Wednesday, September 28, 2011 1:09 PM
-
forgive me if i am saying stupid things. Without timer it is working fine. but each time need to run the application for sync the folders.
My idea is this logic is implemented as windows service and sync the folders at particular interval of time. that is why i have used timer.
Thursday, September 29, 2011 6:44 AM -
the error you are getting is a concurrency issue. two processes trying to access the metadata at the same time. as i have mentioned, if your timer fires, disable it from firing the second time around while you're synching. then enable the timer again after you sync.Thursday, September 29, 2011 7:30 AM
-
Thanks june. it is working fine.Friday, September 30, 2011 7:10 AM