public HttpResponseMessage Post(string name) { if (name.StartsWith(CopyPrefix)) { var targetFileName = GetQueryStringValue("targetFilename"); return(Copy(name.Substring(CopyPrefix.Length), targetFileName)); } name = FileHeader.Canonize(name); var metadata = GetFilteredMetadataFromHeaders(ReadInnerHeaders); var etag = GetEtag(); Storage.Batch(accessor => { Synchronizations.AssertFileIsNotBeingSynced(name); Historian.Update(name, metadata); Files.UpdateMetadata(name, metadata, etag); SynchronizationTask.Context.NotifyAboutWork(); }); return(GetEmptyMessage(HttpStatusCode.NoContent)); }
public HttpResponseMessage Delete(string name) { name = FileHeader.Canonize(name); Storage.Batch(accessor => { Synchronizations.AssertFileIsNotBeingSynced(name); var fileAndPages = accessor.GetFile(name, 0, 0); var metadata = fileAndPages.Metadata; if (metadata == null) { throw new FileNotFoundException(); } if (metadata.Keys.Contains(SynchronizationConstants.RavenDeleteMarker)) { throw new FileNotFoundException(); } Files.IndicateFileToDelete(name, GetEtag()); if (!name.EndsWith(RavenFileNameHelper.DownloadingFileSuffix)) // don't create a tombstone for .downloading file { Files.PutTombstone(name, metadata); accessor.DeleteConfig(RavenFileNameHelper.ConflictConfigNameForFile(name)); // delete conflict item too } }); SynchronizationTask.Context.NotifyAboutWork(); return(GetEmptyMessage(HttpStatusCode.NoContent)); }
public HttpResponseMessage Post(string name) { name = FileHeader.Canonize(name); var metadata = GetFilteredMetadataFromHeaders(ReadInnerHeaders); var etag = GetEtag(); Storage.Batch(accessor => { Synchronizations.AssertFileIsNotBeingSynced(name); Historian.Update(name, metadata); Files.UpdateMetadata(name, metadata, etag); SynchronizationTask.Context.NotifyAboutWork(); }); return(GetEmptyMessage(HttpStatusCode.NoContent)); }
public HttpResponseMessage Post(string name) { name = FileHeader.Canonize(name); var metadata = GetFilteredMetadataFromHeaders(ReadInnerHeaders); var etag = GetEtag(); Storage.Batch(accessor => { Synchronizations.AssertFileIsNotBeingSynced(name); Historian.Update(name, metadata); Files.UpdateMetadata(name, metadata, etag); Synchronizations.StartSynchronizeDestinationsInBackground(); }); //Hack needed by jquery on the client side. We need to find a better solution for this return(GetEmptyMessage(HttpStatusCode.NoContent)); }
private void DeleteFiles(IEnumerable <string> keys, int totalResults, Action <string> progress) { Storage.Batch(accessor => { var files = keys.Select(accessor.ReadFile); foreach (var fileWithIndex in files.Select((value, i) => new { i, value })) { var file = fileWithIndex.value; var fileName = file.FullPath; try { Synchronizations.AssertFileIsNotBeingSynced(fileName); } catch (Exception) { //ignore files that are being synced continue; } var metadata = file.Metadata; if (metadata == null || metadata.Keys.Contains(SynchronizationConstants.RavenDeleteMarker)) { continue; } Historian.Update(fileName, metadata); Files.IndicateFileToDelete(fileName, null); // don't create a tombstone for .downloading file if (!fileName.EndsWith(RavenFileNameHelper.DownloadingFileSuffix)) { Files.PutTombstone(fileName, metadata); accessor.DeleteConfig(RavenFileNameHelper.ConflictConfigNameForFile(fileName)); // delete conflict item too } progress(string.Format("File {0}/{1} was deleted, name: '{2}'.", fileWithIndex.i, totalResults, fileName)); } }); }