mirror of
https://github.com/abraunegg/onedrive
synced 2026-03-14 14:35:46 +01:00
Ensure mkdirRecurse() is correctly wrapped in try block
* Based on an application crash output from OMV, if the client is unable to create the required path, the application crashes. Harden all calls to mkdirRecurse() by wrapping in a try block.
This commit is contained in:
parent
0b65d073eb
commit
0c17baa3a7
2 changed files with 41 additions and 11 deletions
34
src/config.d
34
src/config.d
|
|
@ -569,10 +569,18 @@ class ApplicationConfig {
|
|||
|
||||
// Configuration directory should now have been correctly identified
|
||||
if (!exists(configDirName)) {
|
||||
// create the directory
|
||||
mkdirRecurse(configDirName);
|
||||
// Configure the applicable permissions for the folder
|
||||
configDirName.setAttributes(returnRequiredDirectoryPermissions());
|
||||
// Attempt path creation
|
||||
try {
|
||||
// create the configuration directory
|
||||
mkdirRecurse(configDirName);
|
||||
// Configure the applicable permissions for the folder
|
||||
configDirName.setAttributes(returnRequiredDirectoryPermissions());
|
||||
} catch (std.file.FileException e) {
|
||||
// Creating the configuration directory failed
|
||||
addLogEntry("ERROR: Unable to create the required application configuration directory: " ~ e.msg, ["info", "notify"]);
|
||||
// Use exit scopes to shutdown API
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
// The config path exists
|
||||
// The path that exists must be a directory, not a file
|
||||
|
|
@ -2991,7 +2999,14 @@ class ApplicationConfig {
|
|||
string bookmarksPath = buildPath(expandTilde(environment.get("HOME", "")), ".config", "gtk-3.0", "bookmarks");
|
||||
|
||||
// Ensure the bookmarks path exists
|
||||
mkdirRecurse(dirName(bookmarksPath));
|
||||
try {
|
||||
// Attempt bookmarks path creation
|
||||
mkdirRecurse(dirName(bookmarksPath));
|
||||
} catch (std.file.FileException e) {
|
||||
// Creating the bookmarks path failed
|
||||
addLogEntry("ERROR: Unable to create the GNOME bookmark directory: " ~ e.msg, ["info", "notify"]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Does the bookmark already exist?
|
||||
string content = exists(bookmarksPath) ? readText(bookmarksPath) : "";
|
||||
|
|
@ -3118,7 +3133,14 @@ class ApplicationConfig {
|
|||
string content;
|
||||
|
||||
// Ensure the xbelPath path exists
|
||||
mkdirRecurse(dirName(xbelPath));
|
||||
try {
|
||||
// Attempt xbelPath creation
|
||||
mkdirRecurse(dirName(xbelPath));
|
||||
} catch (std.file.FileException e) {
|
||||
// Creating the xbelPath path failed
|
||||
addLogEntry("ERROR: Unable to create the KDE Places directory: " ~ e.msg, ["info", "notify"]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Does the xbel file exist?
|
||||
if (exists(xbelPath)) {
|
||||
|
|
|
|||
18
src/main.d
18
src/main.d
|
|
@ -910,11 +910,19 @@ int main(string[] cliArgs) {
|
|||
if (!exists(singleDirectoryPath)) {
|
||||
// The requested path to use with --single-directory does not exist locally within the configured 'sync_dir'
|
||||
addLogEntry("WARNING: The requested path for --single-directory does not exist locally. Creating requested path within " ~ runtimeSyncDirectory, ["info", "notify"]);
|
||||
// Make the required --single-directory path locally
|
||||
mkdirRecurse(singleDirectoryPath);
|
||||
// Configure the applicable permissions for the folder
|
||||
if (debugLogging) {addLogEntry("Setting directory permissions for: " ~ singleDirectoryPath, ["debug"]);}
|
||||
singleDirectoryPath.setAttributes(appConfig.returnRequiredDirectoryPermissions());
|
||||
// Attempt path creation
|
||||
try {
|
||||
// Attempt to create the required --single-directory path locally
|
||||
mkdirRecurse(singleDirectoryPath);
|
||||
// Configure the applicable permissions for the folder
|
||||
if (debugLogging) {addLogEntry("Setting directory permissions for: " ~ singleDirectoryPath, ["debug"]);}
|
||||
singleDirectoryPath.setAttributes(appConfig.returnRequiredDirectoryPermissions());
|
||||
} catch (std.file.FileException e) {
|
||||
// Creating the sync directory failed
|
||||
addLogEntry("ERROR: Unable to create the required --single-directory path: " ~ e.msg, ["info", "notify"]);
|
||||
// Use exit scopes to shutdown API
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the paths that we use to perform the sync actions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue