Fix application crash due to access permissions on configured path for sync_dir (#2225)

* Fix application crash due to access permissions on configured path for sync_dir
This commit is contained in:
abraunegg 2022-11-19 08:53:49 +11:00 committed by GitHub
parent 5a7da61cbb
commit 62859609b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,6 +63,8 @@ int main(string[] args)
// Define scopes
scope(exit) {
// detail what scope was called
log.vdebug("Exit scope called");
// Display memory details
if (displayMemoryUsage) {
log.displayMemoryUsagePreGC();
@ -92,6 +94,8 @@ int main(string[] args)
}
scope(failure) {
// detail what scope was called
log.vdebug("Failure scope called");
// Display memory details
if (displayMemoryUsage) {
log.displayMemoryUsagePreGC();
@ -978,20 +982,27 @@ int main(string[] args)
// configure the sync direcory based on syncDir config option
log.vlog("All operations will be performed in: ", syncDir);
if (!exists(syncDir)) {
log.vdebug("syncDir: Configured syncDir is missing. Creating: ", syncDir);
try {
// Attempt to create the sync dir we have been configured with
mkdirRecurse(syncDir);
// Configure the applicable permissions for the folder
log.vdebug("Setting directory permissions for: ", syncDir);
syncDir.setAttributes(cfg.returnRequiredDirectoryPermisions());
} catch (std.file.FileException e) {
// Creating the sync directory failed
log.error("ERROR: Unable to create local OneDrive syncDir - ", e.msg);
// Use exit scopes to shutdown API
return EXIT_FAILURE;
try {
if (!exists(syncDir)) {
log.vdebug("syncDir: Configured syncDir is missing. Creating: ", syncDir);
try {
// Attempt to create the sync dir we have been configured with
mkdirRecurse(syncDir);
// Configure the applicable permissions for the folder
log.vdebug("Setting directory permissions for: ", syncDir);
syncDir.setAttributes(cfg.returnRequiredDirectoryPermisions());
} catch (std.file.FileException e) {
// Creating the sync directory failed
log.error("ERROR: Unable to create local OneDrive syncDir - ", e.msg);
// Use exit scopes to shutdown API
return EXIT_FAILURE;
}
}
} catch (std.file.FileException e) {
// Creating the sync directory failed
log.error("ERROR: Unable to test the configured OneDrive syncDir - ", e.msg);
// Use exit scopes to shutdown API
return EXIT_FAILURE;
}
// Change the working directory to the 'sync_dir' configured item