diff --git a/DragonFruit.Common.Data.Tests/Files/Objects/FileDownloadRequest.cs b/DragonFruit.Common.Data.Tests/Files/Objects/FileDownloadRequest.cs index e2652fb..a3ffea1 100644 --- a/DragonFruit.Common.Data.Tests/Files/Objects/FileDownloadRequest.cs +++ b/DragonFruit.Common.Data.Tests/Files/Objects/FileDownloadRequest.cs @@ -6,8 +6,16 @@ namespace DragonFruit.Common.Data.Tests.Files.Objects /// /// Simple file download request with a path and a destination /// - public class FileDownloadRequest : ApiFileRequest + internal sealed class FileDownloadRequest : ApiFileRequest { + public FileDownloadRequest() + { + if (System.IO.File.Exists(Destination)) + { + System.IO.File.Delete(Destination); + } + } + public override string Path => "https://github.com/ppy/osu/archive/2020.327.0.zip"; public override string Destination => System.IO.Path.Combine(System.IO.Path.GetTempPath(), "file.zip"); diff --git a/DragonFruit.Common.Data/ApiClient.cs b/DragonFruit.Common.Data/ApiClient.cs index cae0940..9d05336 100644 --- a/DragonFruit.Common.Data/ApiClient.cs +++ b/DragonFruit.Common.Data/ApiClient.cs @@ -350,10 +350,7 @@ protected T InternalPerform(HttpRequestMessage request, Func protected virtual T ValidateAndProcess(HttpResponseMessage response, HttpRequestMessage request) where T : class { - if (!response.IsSuccessStatusCode) - { - throw new HttpRequestException($"Response was unsuccessful ({response.StatusCode})"); - } + response.EnsureSuccessStatusCode(); using var stream = response.Content.ReadAsStreamAsync().Result; return Serializer.Deserialize(stream);