public bool Delete(DeleteOprationInfo deleteInfo)
        {
            var rootPath = HostingEnvironment.ApplicationHost.GetPhysicalPath();
            var tempPath = _fileSystemManager.RelativeToAbsolutePath(Config.ThumbnailPath);

            if (tempPath == null)
            {
                throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, Config.ThumbnailPath));
            }

            var thumbnailRootPath = tempPath.ToLower();

            var path = _fileSystemManager.RelativeToAbsolutePath(AuthorizeManager.AuthorizeActionOnPath(deleteInfo.Path, ActionKey.DeleteFromDisk));

            if (path == null)
            {
                throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, deleteInfo.Path));
            }



            Parallel.ForEach(deleteInfo.Files, file =>
            {
                var realPath = path + "/" + file;
                _fileSystemManager.DeleteFile(realPath);

                var thumbnailPath = realPath.Substring(rootPath.Length);

                if (_fileSystemManager.FileExist(thumbnailRootPath + thumbnailPath))
                {
                    _fileSystemManager.DeleteFile(thumbnailRootPath + thumbnailPath);
                }
            });
            Parallel.ForEach(deleteInfo.Folders, folder =>
            {
                var realPath = path + "/" + folder;
                _fileSystemManager.DeleteDirectory(realPath);

                var thumbnailPath = realPath.Substring(rootPath.Length);

                if (_fileSystemManager.DirectoryExists(thumbnailRootPath + thumbnailPath))
                {
                    _fileSystemManager.DeleteDirectory(thumbnailRootPath + thumbnailPath);
                }
            });
            return(true);
        }
Esempio n. 2
0
 public void Destroy()
 {
     try
     {
         fileSystem.DeleteDirectory(containerPath);
     }
     catch (DirectoryNotFoundException)
     {
     }
 }
Esempio n. 3
0
 protected override DeploymentStepStatus DoExecute()
 {
     if (_fileSystemManager.DirectoryExists(Parameters.TempDirectoryPath))
     {
         var tempDirectory = new DirectoryInfo(Parameters.TempDirectoryPath);
         Status.AppendDetailsLine("Removing tempdir " + tempDirectory.FullName);
         _fileSystemManager.DeleteDirectory(tempDirectory);
     }
     else
     {
         Status.AppendDetailsLine(Parameters.TempDirectoryPath + " does not exitst. Nothing to remove.");
     }
     return(Status);
 }
Esempio n. 4
0
 protected bool DeleteDirectory(string path)
 {
     return(FileSystemManager.DeleteDirectory(AuthorizeManager.AuthorizeActionOnPath(path, ActionKey.DeleteFromDisk)));
 }