diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-03-08 02:24:30 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-08 02:24:30 -0500 |
| commit | 23010f2980381a4b56e05620d4604cafc0e00043 (patch) | |
| tree | 418b4ad6964c84d17ff9c33fa88b0e1a8bcacd34 /Emby.Server.Implementations/Library/LibraryManager.cs | |
| parent | 0ac0a09c806112ce82dcd23f43c7df9ff8b5531d (diff) | |
| parent | 314b84ae9ef5a692144b0a3a178ddcbd393c9fb9 (diff) | |
Merge pull request #2516 from MediaBrowser/beta
Beta
Diffstat (limited to 'Emby.Server.Implementations/Library/LibraryManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Library/LibraryManager.cs | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 56bffc233..f7706db47 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -409,24 +409,46 @@ namespace Emby.Server.Implementations.Library if (options.DeleteFileLocation && locationType != LocationType.Remote && locationType != LocationType.Virtual) { + // Assume only the first is required + // Add this flag to GetDeletePaths if required in the future + var isRequiredForDelete = true; + foreach (var fileSystemInfo in item.GetDeletePaths().ToList()) { - if (fileSystemInfo.IsDirectory) + try { - _logger.Debug("Deleting path {0}", fileSystemInfo.FullName); - _fileSystem.DeleteDirectory(fileSystemInfo.FullName, true); + if (fileSystemInfo.IsDirectory) + { + _logger.Debug("Deleting path {0}", fileSystemInfo.FullName); + _fileSystem.DeleteDirectory(fileSystemInfo.FullName, true); + } + else + { + _logger.Debug("Deleting path {0}", fileSystemInfo.FullName); + _fileSystem.DeleteFile(fileSystemInfo.FullName); + } } - else + catch (IOException) { - _logger.Debug("Deleting path {0}", fileSystemInfo.FullName); - _fileSystem.DeleteFile(fileSystemInfo.FullName); + if (isRequiredForDelete) + { + throw; + } } + catch (UnauthorizedAccessException) + { + if (isRequiredForDelete) + { + throw; + } + } + + isRequiredForDelete = false; } if (parent != null) { - await parent.ValidateChildren(new Progress<double>(), CancellationToken.None) - .ConfigureAwait(false); + await parent.ValidateChildren(new Progress<double>(), CancellationToken.None, new MetadataRefreshOptions(_fileSystem), false) .ConfigureAwait(false); } } else if (parent != null) |
