fixes, errors handling

This commit is contained in:
2024-03-10 01:52:23 +01:00
Unverified
parent d73ce6a05b
commit f0894c0ccd
5 changed files with 83 additions and 27 deletions

View File

@@ -145,15 +145,17 @@ namespace VDownload.Sources.Twitch.Models
{
token.ThrowIfCancellationRequested();
using (FileStream inputStream = File.OpenRead(path))
using (FileStream inputStream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
{
inputStream.CopyTo(outputStream);
}
if (deleteSource)
{
File.Delete(path);
}
}
}
foreach (string item in sourceFiles)
{
if (deleteSource)
{
File.Delete(item);
}
}
}
@@ -184,10 +186,7 @@ namespace VDownload.Sources.Twitch.Models
int retriesCount = 0;
while (true)
{
if (token.IsCancellationRequested)
{
return;
}
token.ThrowIfCancellationRequested();
try
{
byte[] data = await _httpClient.GetByteArrayAsync(chunk.Url, token);
@@ -195,10 +194,6 @@ namespace VDownload.Sources.Twitch.Models
onTaskEndSuccessfully.Invoke();
return;
}
catch (OperationCanceledException)
{
return;
}
catch (Exception ex) when (ex is HttpRequestException || ex is TaskCanceledException)
{
if (_settingsService.Data.Twitch.Vod.ChunkDownloadingError.Retry && retriesCount < _settingsService.Data.Twitch.Vod.ChunkDownloadingError.RetriesCount)