Check for existence before trying to delete directory

This commit is contained in:
Shadowghost 2024-06-09 08:24:58 +02:00
parent b63f7a2bc0
commit 8b442a7749
2 changed files with 2 additions and 2 deletions

View File

@ -194,7 +194,7 @@ namespace MediaBrowser.Providers.Manager
if (item is Episode && directory.Equals("metadata", StringComparison.Ordinal)) if (item is Episode && directory.Equals("metadata", StringComparison.Ordinal))
{ {
var parentDirectoryPath = Directory.GetParent(currentPath).FullName; var parentDirectoryPath = Directory.GetParent(currentPath).FullName;
if (!_fileSystem.GetFiles(parentDirectoryPath).Any()) if (_fileSystem.DirectoryExists(parentDirectoryPath) && !_fileSystem.GetFiles(parentDirectoryPath).Any())
{ {
try try
{ {

View File

@ -384,7 +384,7 @@ namespace MediaBrowser.Providers.Manager
{ {
var oldLocalMetadataDirectory = Path.Combine(item.ContainingFolderPath, "metadata"); var oldLocalMetadataDirectory = Path.Combine(item.ContainingFolderPath, "metadata");
var localImages = images.Where(i => i.Path.StartsWith(oldLocalMetadataDirectory, StringComparison.Ordinal)).ToList(); var localImages = images.Where(i => i.Path.StartsWith(oldLocalMetadataDirectory, StringComparison.Ordinal)).ToList();
if (!_fileSystem.GetFiles(oldLocalMetadataDirectory).Any()) if (_fileSystem.DirectoryExists(oldLocalMetadataDirectory) && !_fileSystem.GetFiles(oldLocalMetadataDirectory).Any())
{ {
Directory.Delete(oldLocalMetadataDirectory); Directory.Delete(oldLocalMetadataDirectory);
} }