예제 #1
0
		protected StorageStream(ITransactionalStorage transactionalStorage, string fileName,
								StorageStreamAccess storageStreamAccess,
								NameValueCollection metadata, IndexStorage indexStorage, StorageOperationsTask operations)
		{
			TransactionalStorage = transactionalStorage;
			StorageStreamAccess = storageStreamAccess;
			Name = fileName;

			switch (storageStreamAccess)
			{
				case StorageStreamAccess.Read:
					TransactionalStorage.Batch(accessor => fileHeader = accessor.ReadFile(fileName));
					if (fileHeader.TotalSize == null)
					{
						throw new FileNotFoundException("File is not uploaded yet");
					}
					Metadata = fileHeader.Metadata;
					Seek(0, SeekOrigin.Begin);
					break;
				case StorageStreamAccess.CreateAndWrite:
					TransactionalStorage.Batch(accessor =>
					{
						operations.IndicateFileToDelete(fileName);
						accessor.PutFile(fileName, null, metadata);
						indexStorage.Index(fileName, metadata);
					});
					Metadata = metadata;
					break;
				default:
					throw new ArgumentOutOfRangeException("storageStreamAccess", storageStreamAccess, "Unknown value");
			}
		}
예제 #2
0
		public bool Filter(FileHeader file, Guid destinationId, IEnumerable<FileHeader> candidatesToSynchronization)
		{
			// prevent synchronization back to source
			if (file.Metadata[SynchronizationConstants.RavenSynchronizationSource] == destinationId.ToString())
				return false;

			if (file.Name.EndsWith(RavenFileNameHelper.DownloadingFileSuffix))
				return false;

			if (file.Name.EndsWith(RavenFileNameHelper.DeletingFileSuffix))
				return false;

			if (file.IsFileBeingUploadedOrUploadHasBeenBroken())
				return false;

			if (ExistsRenameTombstone(file.Name, candidatesToSynchronization))
				return false;

			return true;
		}
예제 #3
0
		protected bool Equals(FileHeader other)
		{
			return string.Equals(Name, other.Name) && TotalSize == other.TotalSize && UploadedSize == other.UploadedSize && Equals(Metadata, other.Metadata);
		}
예제 #4
0
 protected bool Equals(FileHeader other)
 {
     return(string.Equals(Name, other.Name) && TotalSize == other.TotalSize && UploadedSize == other.UploadedSize && Equals(Metadata, other.Metadata));
 }