summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Belt <andrewpbelt@gmail.com>2024-04-15 20:46:34 -0400
committerAndrew Belt <andrewpbelt@gmail.com>2024-04-15 20:46:34 -0400
commitfe816b9716c87fe7c39fbaef45ffe87d664725e3 (patch)
treeae20186c800ee4bc8816c598d73c3500689298ce
parent6c18b05ac7d779bc4b9dccbf264e04023be63169 (diff)
Add error dialog if moving old user dir to new dir fails.
-rw-r--r--src/asset.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/asset.cpp b/src/asset.cpp
index eab8f2a7..df820239 100644
--- a/src/asset.cpp
+++ b/src/asset.cpp
@@ -165,14 +165,25 @@ static void initUserDir() {
oldUserDir = system::join(homeDir, ".Rack" + APP_VERSION_MAJOR);
#endif
- // If userDir doesn't exist but oldUserDir does, move it and inform user.
+ // If userDir doesn't exist but oldUserDir does, attempt to move it and inform user.
if (!oldUserDir.empty() && !system::isDirectory(userDir) && system::isDirectory(oldUserDir)) {
- system::rename(oldUserDir, userDir);
- std::string msg = APP_NAME + "'s user folder has been moved from";
- msg += "\n" + oldUserDir;
- msg += "\nto";
- msg += "\n" + userDir;
- osdialog_message(OSDIALOG_INFO, OSDIALOG_OK, msg.c_str());
+ if (system::rename(oldUserDir, userDir)) {
+ std::string msg = APP_NAME + "'s user folder has been moved from";
+ msg += "\n" + oldUserDir;
+ msg += "\nto";
+ msg += "\n" + userDir;
+ osdialog_message(OSDIALOG_INFO, OSDIALOG_OK, msg.c_str());
+ }
+ else {
+ std::string msg = "Failed to move " + APP_NAME + "'s user folder from";
+ msg += "\n" + oldUserDir;
+ msg += "\nto";
+ msg += "\n" + userDir;
+ msg += "\ndue to insufficient access permissions. Consider moving this folder manually to ensure compatibility with future versions.";
+ osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, msg.c_str());
+ // Move failed, just use the old dir instead
+ userDir = oldUserDir;
+ }
}
// Create user dir if it doesn't exist