diff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.cs index e8eece299..4542c9c42 100644 --- a/MediaBrowser.Providers/Manager/ImageSaver.cs +++ b/MediaBrowser.Providers/Manager/ImageSaver.cs @@ -133,6 +133,7 @@ namespace MediaBrowser.Providers.Manager source = memoryStream; var currentImage = GetCurrentImage(item, type, index); + var savedPaths = new List(); using (source) { @@ -146,17 +147,17 @@ namespace MediaBrowser.Providers.Manager { retryPath = retryPaths[currentPathIndex]; } - await SaveImageToLocation(source, path, retryPath, cancellationToken).ConfigureAwait(false); - + var savedPath = await SaveImageToLocation(source, path, retryPath, cancellationToken).ConfigureAwait(false); + savedPaths.Add(savedPath); currentPathIndex++; } } // Set the path into the item - SetImagePath(item, type, imageIndex, paths[0]); + SetImagePath(item, type, imageIndex, savedPaths[0]); // Delete the current path - if (currentImage != null && currentImage.IsLocalFile && !paths.Contains(currentImage.Path, StringComparer.OrdinalIgnoreCase)) + if (currentImage != null && currentImage.IsLocalFile && !savedPaths.Contains(currentImage.Path, StringComparer.OrdinalIgnoreCase)) { var currentPath = currentImage.Path; @@ -184,11 +185,12 @@ namespace MediaBrowser.Providers.Manager } } - private async Task SaveImageToLocation(Stream source, string path, string retryPath, CancellationToken cancellationToken) + private async Task SaveImageToLocation(Stream source, string path, string retryPath, CancellationToken cancellationToken) { try { await SaveImageToLocation(source, path, cancellationToken).ConfigureAwait(false); + return path; } catch (UnauthorizedAccessException) { @@ -207,6 +209,7 @@ namespace MediaBrowser.Providers.Manager source.Position = 0; await SaveImageToLocation(source, retryPath, cancellationToken).ConfigureAwait(false); + return retryPath; } ///