|
@@ -5,6 +5,7 @@ using System.Linq;
|
|
|
using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
using MediaBrowser.Common.Configuration;
|
|
|
+using MediaBrowser.Controller.IO;
|
|
|
using MediaBrowser.Model.Globalization;
|
|
|
using MediaBrowser.Model.IO;
|
|
|
using MediaBrowser.Model.Tasks;
|
|
@@ -133,53 +134,14 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
|
|
|
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
- DeleteFile(file.FullName);
|
|
|
+ FileSystemHelper.DeleteFile(_fileSystem, file.FullName, _logger);
|
|
|
|
|
|
index++;
|
|
|
}
|
|
|
|
|
|
- DeleteEmptyFolders(directory);
|
|
|
+ FileSystemHelper.DeleteEmptyFolders(_fileSystem, directory, _logger);
|
|
|
|
|
|
progress.Report(100);
|
|
|
}
|
|
|
-
|
|
|
- private void DeleteEmptyFolders(string parent)
|
|
|
- {
|
|
|
- foreach (var directory in _fileSystem.GetDirectoryPaths(parent))
|
|
|
- {
|
|
|
- DeleteEmptyFolders(directory);
|
|
|
- if (!_fileSystem.GetFileSystemEntryPaths(directory).Any())
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- Directory.Delete(directory, false);
|
|
|
- }
|
|
|
- catch (UnauthorizedAccessException ex)
|
|
|
- {
|
|
|
- _logger.LogError(ex, "Error deleting directory {Path}", directory);
|
|
|
- }
|
|
|
- catch (IOException ex)
|
|
|
- {
|
|
|
- _logger.LogError(ex, "Error deleting directory {Path}", directory);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void DeleteFile(string path)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- _fileSystem.DeleteFile(path);
|
|
|
- }
|
|
|
- catch (UnauthorizedAccessException ex)
|
|
|
- {
|
|
|
- _logger.LogError(ex, "Error deleting file {Path}", path);
|
|
|
- }
|
|
|
- catch (IOException ex)
|
|
|
- {
|
|
|
- _logger.LogError(ex, "Error deleting file {Path}", path);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|