diff --git a/Tools/AutoClient/Purchaser.cs b/Tools/AutoClient/Purchaser.cs index 0baec98..97f9061 100644 --- a/Tools/AutoClient/Purchaser.cs +++ b/Tools/AutoClient/Purchaser.cs @@ -84,8 +84,15 @@ namespace AutoClient private async Task StartNewPurchase() { var file = await CreateFile(); - var cid = await UploadFile(file); - return await RequestStorage(cid); + try + { + var cid = await UploadFile(file); + return await RequestStorage(cid); + } + finally + { + DeleteFile(file); + } } private async Task CreateFile() @@ -93,6 +100,18 @@ namespace AutoClient return await app.Generator.Generate(); } + private void DeleteFile(string file) + { + try + { + File.Delete(file); + } + catch (Exception exc) + { + app.Log.Error($"Failed to delete file '{file}': {exc}"); + } + } + private async Task UploadFile(string filename) { using var fileStream = File.OpenRead(filename);