mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-17 05:06:55 +02:00
Fix download failure due to incorrect filesystem permissions
* Add try block for opening new file for writing when downloading a new file to catch any read only file systems * Move set file attributes to master function, incase there is a download failure, exit scope cannot set attributes on a file that is non existent
This commit is contained in:
parent
cb57213fb9
commit
aa47f1119f
|
@ -501,7 +501,13 @@ final class OneDriveApi
|
|||
// Configure the applicable permissions for the folder
|
||||
newPath.setAttributes(cfg.returnRequiredDirectoryPermisions());
|
||||
const(char)[] url = driveByIdUrl ~ driveId ~ "/items/" ~ id ~ "/content?AVOverride=1";
|
||||
// Download file
|
||||
download(url, saveToPath, fileSize);
|
||||
// Does path exist?
|
||||
if (exists(saveToPath)) {
|
||||
// File was downloaded sucessfully - configure the applicable permissions for the file
|
||||
saveToPath.setAttributes(cfg.returnRequiredFilePermisions());
|
||||
}
|
||||
}
|
||||
|
||||
// https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content
|
||||
|
@ -797,8 +803,14 @@ 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");
|
||||
|
||||
try {
|
||||
// open file as write in binary mode
|
||||
auto file = File(filename, "wb");
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
}
|
||||
|
||||
// function scopes
|
||||
scope(exit) {
|
||||
|
@ -818,8 +830,6 @@ final class OneDriveApi
|
|||
// close open file
|
||||
file.close();
|
||||
}
|
||||
// Configure the applicable permissions for the file
|
||||
filename.setAttributes(cfg.returnRequiredFilePermisions());
|
||||
}
|
||||
|
||||
http.method = HTTP.Method.get;
|
||||
|
|
Loading…
Reference in a new issue