Browse Source

Add error dialog if moving old user dir to new dir fails.

tags/v2.5.1
Andrew Belt 6 months ago
parent
commit
fe816b9716
1 changed files with 18 additions and 7 deletions
  1. +18
    -7
      src/asset.cpp

+ 18
- 7
src/asset.cpp View File

@@ -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


Loading…
Cancel
Save