public void RenameFile(RenameFileOperation operation)
		{
			var configName = RavenFileNameHelper.RenameOperationConfigNameForFile(operation.Name);
			notificationPublisher.Publish(new FileChange
				{
					File = FilePathTools.Cannoicalise(operation.Name),
					Action = FileChangeAction.Renaming
				});

			storage.Batch(accessor =>
				{
					var previousRenameTombstone = accessor.ReadFile(operation.Rename);

					if (previousRenameTombstone != null &&
					    previousRenameTombstone.Metadata[SynchronizationConstants.RavenDeleteMarker] != null)
					{
						// if there is a tombstone delete it
						accessor.Delete(previousRenameTombstone.Name);
					}

					accessor.RenameFile(operation.Name, operation.Rename, true);
					accessor.UpdateFileMetadata(operation.Rename, operation.MetadataAfterOperation);

					// copy renaming file metadata and set special markers
					var tombstoneMetadata =
						new NameValueCollection(operation.MetadataAfterOperation).WithRenameMarkers(operation.Rename);

					accessor.PutFile(operation.Name, 0, tombstoneMetadata, true); // put rename tombstone

					accessor.DeleteConfig(configName);

					search.Delete(operation.Name);
					search.Index(operation.Rename, operation.MetadataAfterOperation);
				});

			notificationPublisher.Publish(new ConfigChange {Name = configName, Action = ConfigChangeAction.Set});
			notificationPublisher.Publish(new FileChange
				{
					File = FilePathTools.Cannoicalise(operation.Rename),
					Action = FileChangeAction.Renamed
				});
		}
		public HttpResponseMessage Patch(string name, string rename)
		{
			name = RavenFileNameHelper.RavenPath(name);
			rename = RavenFileNameHelper.RavenPath(rename);

			try
			{
				ConcurrencyAwareExecutor.Execute(() =>
				                                 Storage.Batch(accessor =>
					                                               {
						                                               AssertFileIsNotBeingSynced(name, accessor, true);

						                                               var metadata = accessor.GetFile(name, 0, 0).Metadata;

						                                               if (
							                                               metadata.AllKeys.Contains(
								                                               SynchronizationConstants.RavenDeleteMarker))
						                                               {
							                                               throw new FileNotFoundException();
						                                               }

						                                               var existingHeader = accessor.ReadFile(rename);
						                                               if (existingHeader != null &&
						                                                   !existingHeader.Metadata.AllKeys.Contains(
							                                                   SynchronizationConstants.RavenDeleteMarker))
						                                               {
							                                               throw new HttpResponseException(
								                                               Request.CreateResponse(HttpStatusCode.Forbidden,
								                                                                      new InvalidOperationException(
									                                                                      "Cannot rename because file " + rename +
									                                                                      " already exists")));
						                                               }

						                                               Historian.UpdateLastModified(metadata);

						                                               var operation = new RenameFileOperation
							                                                               {
								                                                               Name = name,
								                                                               Rename = rename,
								                                                               MetadataAfterOperation = metadata
							                                                               };

						                                               accessor.SetConfig(
							                                               RavenFileNameHelper.RenameOperationConfigNameForFile(name),
							                                               operation.AsConfig());
						                                               accessor.PulseTransaction(); // commit rename operation config

						                                               StorageOperationsTask.RenameFile(operation);
					                                               }), ConcurrencyResponseException);
			}
			catch (FileNotFoundException)
			{
				log.Debug("Cannot rename a file '{0}' to '{1}' because a file was not found", name, rename);
				return new HttpResponseMessage(HttpStatusCode.NotFound);
			}

			log.Debug("File '{0}' was renamed to '{1}'", name, rename);

			StartSynchronizeDestinationsInBackground();

			return new HttpResponseMessage(HttpStatusCode.NoContent);
		}