mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 21:27:21 +01:00
delete empty files on failed downloads
This commit is contained in:
parent
189ec03173
commit
fc4cee1a3a
1 changed files with 20 additions and 12 deletions
|
|
@ -50,6 +50,8 @@ public partial class ApiController
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
var fileName = Path.GetTempFileName();
|
var fileName = Path.GetTempFileName();
|
||||||
|
try
|
||||||
|
{
|
||||||
var fileStream = File.Create(fileName);
|
var fileStream = File.Create(fileName);
|
||||||
await using (fileStream.ConfigureAwait(false))
|
await using (fileStream.ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
|
|
@ -69,6 +71,12 @@ public partial class ApiController
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
File.Delete(fileName);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int GetDownloadId() => _downloadId++;
|
public int GetDownloadId() => _downloadId++;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue