Esempio n. 1
0
        public List <string> EnumerateSubFolders(string relativePath)
        {
            if (String.IsNullOrEmpty(relativePath))
            {
                throw new ArgumentException();
            }

            var remotePath = Path.Combine(this.storeInformation.Path, relativePath);

            try
            {
                var enumerateInfo = new FolderEnumerateInfo
                {
                    DirectoryPath = remotePath,
                    GetFullPath   = false
                };

                BackupRestoreUtility.PerformIOWithRetries(
                    enumInfo =>
                {
                    PerformDestinationOperation(EnumerateFolders, enumInfo);
                },
                    enumerateInfo);

                return(enumerateInfo.SubFolders.ToList());
            }
            catch (Exception e)
            {
                throw new IOException(String.Format("Unable to enumerate sub folders from location {0}.", remotePath), e);
            }
        }
Esempio n. 2
0
        public IEnumerable <string> ListFolders(string directory, string directoryContinuationToken = null)
        {
            var directoryEnumerateInfo = new FolderEnumerateInfo()
            {
                DirectoryPath = directory,
                DirectoryPathContinuationToken = directoryContinuationToken,
                GetFullPath = true
            };

            BackupRestoreUtility.PerformIOWithRetries(
                enumInfo =>
            {
                PerformDestinationOperation(EnumerateFolders, enumInfo);
            },
                directoryEnumerateInfo);
            return(directoryEnumerateInfo.SubFolders);
        }
Esempio n. 3
0
        private void DeleteFolderOrFile(string relativefilePathOrSourceFolderPath, bool isFolder)
        {
            var remotePath = Path.Combine(this.storeInformation.Path, relativefilePathOrSourceFolderPath);

            if (!CheckIfBackupExists(remotePath))
            {
                BackupRestoreTrace.TraceSource.WriteWarning("FileShareRecoveryPointManager", "relativefilePathOrSourceFolderPath: {0} with storePath : {1} not found"
                                                            , relativefilePathOrSourceFolderPath, this.storeInformation.Path);
                return;
            }
            if (isFolder)
            {
                var enumerateInfo = new FileEnumerateInfo
                {
                    DirectoryPath    = remotePath,
                    SearchOptionEnum = SearchOption.AllDirectories
                };

                BackupRestoreUtility.PerformIOWithRetries(
                    enumInfo =>
                {
                    PerformDestinationOperation(EnumerateFiles, enumInfo);
                },
                    enumerateInfo);

                List <string> filePathList = enumerateInfo.Files.ToList();
                foreach (var filePath in filePathList)
                {
                    BackupRestoreUtility.PerformIOWithRetries(
                        file =>
                    {
                        PerformDestinationOperation(DeleteFile, file);
                    },
                        filePath);
                }
            }
            else
            {
                BackupRestoreUtility.PerformIOWithRetries(
                    file =>
                {
                    PerformDestinationOperation(DeleteFile, file);
                },
                    remotePath);
            }
        }
Esempio n. 4
0
        public IEnumerable <string> ListMetadataFilesInTheFolder(string directoryName)
        {
            var enumerateInfo = new FileEnumerateInfo
            {
                DirectoryPath    = directoryName,
                FileExtension    = "*" + RecoveryPointMetadataFileExtension,
                SearchOptionEnum = SearchOption.TopDirectoryOnly
            };

            BackupRestoreUtility.PerformIOWithRetries(
                enumInfo =>
            {
                PerformDestinationOperation(EnumerateFiles, enumInfo);
            },
                enumerateInfo);

            return(enumerateInfo.Files);
        }
        public static void DeleteBlob(CloudBlockBlob cloudBlockBlob)
        {
            try
            {
                BackupRestoreUtility.PerformIOWithRetries(
                    () =>
                {
                    cloudBlockBlob.DeleteIfExists();
                },
                    RetryCount);
            }
            catch (Exception e)
            {
                TraceSource.WriteExceptionAsError(
                    TraceType,
                    e,
                    "Failed to list blobs under directory {0} .",
                    cloudBlockBlob.Name);

                throw;
            }
        }