public HttpResponseMessage ResolveConflict(string filename, ConflictResolutionStrategy strategy) { var canonicalFilename = FileHeader.Canonize(filename); Log.Debug("Resolving conflict of a file '{0}' by using {1} strategy", filename, strategy); switch (strategy) { case ConflictResolutionStrategy.CurrentVersion: Storage.Batch(accessor => { var localMetadata = accessor.GetFile(canonicalFilename, 0, 0).Metadata; var conflict = accessor.GetConfigurationValue <ConflictItem>(RavenFileNameHelper.ConflictConfigNameForFile(canonicalFilename)); ConflictResolver.ApplyCurrentStrategy(canonicalFilename, conflict, localMetadata); accessor.UpdateFileMetadata(canonicalFilename, localMetadata, null); ConflictArtifactManager.Delete(canonicalFilename, accessor); }); Publisher.Publish(new ConflictNotification { FileName = filename, Status = ConflictStatus.Resolved }); break; case ConflictResolutionStrategy.RemoteVersion: Storage.Batch(accessor => { var localMetadata = accessor.GetFile(canonicalFilename, 0, 0).Metadata; var conflict = accessor.GetConfig(RavenFileNameHelper.ConflictConfigNameForFile(canonicalFilename)).JsonDeserialization <ConflictItem>(); ConflictResolver.ApplyRemoteStrategy(canonicalFilename, conflict, localMetadata); accessor.UpdateFileMetadata(canonicalFilename, localMetadata, null); // ConflictArtifactManager.Delete(canonicalFilename, accessor); - intentionally not deleting, conflict item will be removed when a remote file is put }); Task.Run(() => SynchronizationTask.Execute(true)); break; default: throw new NotSupportedException(string.Format("{0} is not the valid strategy to resolve a conflict", strategy)); } return(GetEmptyMessage(HttpStatusCode.NoContent)); }
public async Task <HttpResponseMessage> ToDestinations(bool forceSyncingAll) { var tasks = SynchronizationTask.Execute(forceSyncingAll); var result = new List <DestinationSyncResult>(); foreach (var task in tasks) { result.Add(await SynchronizationTask.CreateDestinationResult(task.Key, await task.Value)); } return(GetMessageWithObject(result.ToArray())); }
public void StartSynchronizeDestinationsInBackground() { Task.Factory.StartNew(() => SynchronizationTask.Execute(false), CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); }
public async Task <HttpResponseMessage> ToDestinations(bool forceSyncingAll) { var result = await SynchronizationTask.Execute(forceSyncingAll); return(GetMessageWithObject(result)); }