mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 19:37:55 +02:00
update image saver
This commit is contained in:
parent
0355ada899
commit
268b1c7916
1 changed files with 8 additions and 5 deletions
|
@ -133,6 +133,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
source = memoryStream;
|
source = memoryStream;
|
||||||
|
|
||||||
var currentImage = GetCurrentImage(item, type, index);
|
var currentImage = GetCurrentImage(item, type, index);
|
||||||
|
var savedPaths = new List<string>();
|
||||||
|
|
||||||
using (source)
|
using (source)
|
||||||
{
|
{
|
||||||
|
@ -146,17 +147,17 @@ namespace MediaBrowser.Providers.Manager
|
||||||
{
|
{
|
||||||
retryPath = retryPaths[currentPathIndex];
|
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++;
|
currentPathIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the path into the item
|
// Set the path into the item
|
||||||
SetImagePath(item, type, imageIndex, paths[0]);
|
SetImagePath(item, type, imageIndex, savedPaths[0]);
|
||||||
|
|
||||||
// Delete the current path
|
// 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;
|
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<string> SaveImageToLocation(Stream source, string path, string retryPath, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await SaveImageToLocation(source, path, cancellationToken).ConfigureAwait(false);
|
await SaveImageToLocation(source, path, cancellationToken).ConfigureAwait(false);
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
catch (UnauthorizedAccessException)
|
catch (UnauthorizedAccessException)
|
||||||
{
|
{
|
||||||
|
@ -207,6 +209,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
|
|
||||||
source.Position = 0;
|
source.Position = 0;
|
||||||
await SaveImageToLocation(source, retryPath, cancellationToken).ConfigureAwait(false);
|
await SaveImageToLocation(source, retryPath, cancellationToken).ConfigureAwait(false);
|
||||||
|
return retryPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue