Ejemplo n.º 1
0
        public void CreateParentDirectory(SingleObjectTransfer transfer)
        {
            switch (transfer.Destination.Type)
            {
            case TransferLocationType.FilePath:
                var filePath = (transfer.Destination as FileLocation).FilePath;
                Utils.ValidateDestinationPath(transfer.Source.Instance.ConvertToString(), filePath);
                filePath = filePath.ToLongPath();
                Utils.CreateParentDirectoryIfNotExists(filePath);
                break;

            case TransferLocationType.AzureFile:
                try
                {
                    CreateParentDirectoryIfNotExists((transfer.Destination as AzureFileLocation).AzureFile);
                }
                catch (Exception ex)
                {
                    AggregateException aggregateException = ex as AggregateException;
                    StorageException   storageException   = null;
                    if (aggregateException != null)
                    {
                        storageException = aggregateException.Flatten().InnerExceptions[0] as StorageException;
                    }

                    if (storageException == null)
                    {
                        storageException = ex as StorageException;
                    }

                    if (storageException != null)
                    {
                        throw new TransferException(TransferErrorCode.FailToVadlidateDestination,
                                                    string.Format(CultureInfo.CurrentCulture,
                                                                  Resources.FailedToValidateDestinationException,
                                                                  storageException.ToErrorDetail()),
                                                    storageException);
                    }

                    throw;
                }
                break;

            default:
                break;
            }
        }