Skip to content

Commit

Permalink
fix(web): DownloadToFile()
Browse files Browse the repository at this point in the history
- It's now a function instead of a procedure that returns the http code response.
- Automatically deletes the file it creates if the response code is not between 200 and 299
  • Loading branch information
Torwent committed Oct 31, 2024
1 parent 30df6ce commit d5db91c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils/web.simba
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ begin
end;
end;

procedure DownloadToFile(const url, fileName: String; force: Boolean = False);
function DownloadToFile(const url, fileName: String; force: Boolean = False): Int32;
var
client: Int32;
path: String;
Expand All @@ -33,8 +33,9 @@ begin

client := InitializeHTTPClient(False);
try
GetHTTPPageEx(client, url, fileName);
Result := GetHTTPPageEx(client, url, fileName);
finally
FreeHTTPClient(client);
if not InRange(Result, 200, 299) then DeleteFile(fileName);
end;
end;

0 comments on commit d5db91c

Please sign in to comment.