Implement feature request to mark partially-downloaded files as .partial (#1868)

* Implement feature request to mark partially-downloaded files as .partial during download
This commit is contained in:
abraunegg 2022-03-10 07:01:08 +11:00 committed by GitHub
parent 3124b2dcf2
commit a5bd4e9133
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1158,8 +1158,13 @@ final class OneDriveApi
{
// Threshold for displaying download bar
long thresholdFileSize = 4 * 2^^20; // 4 MiB
// open file as write in binary mode
auto file = File(filename, "wb");
// To support marking of partially-downloaded files,
string originalFilename = filename;
string downloadFilename = filename ~ ".partial";
// open downloadFilename as write in binary mode
auto file = File(downloadFilename, "wb");
// function scopes
scope(exit) {
@ -1253,6 +1258,9 @@ final class OneDriveApi
}
}
// Rename downloaded file
rename(downloadFilename, originalFilename);
// Check the HTTP response code, which, if a 429, will also check response headers
checkHttpCode();
}