Updated settings folder handling when in single user mode (see #4428)

This commit is contained in:
Hombre
2018-03-09 00:35:37 +01:00
parent 478e1c05b6
commit d86262162b
2 changed files with 44 additions and 56 deletions

View File

@@ -121,11 +121,14 @@ void ProfileStore::_parseProfiles ()
Glib::ustring p2 = options.getGlobalProfilePath();
bool displayLevel0 = options.useBundledProfiles && !p1.empty() && !p2.empty() && p1 != p2;
Glib::ustring virtualPath ("${U}");
Glib::ustring currDir ("${U}");
Glib::ustring virtualPath;
Glib::ustring currDir;
if (!p1.empty()) {
virtualPath = "${U}";
currDir = "${U}";
parseDir (p1, virtualPath, currDir, 0, 0, displayLevel0);
if (displayLevel0) {
}
if (p1.empty() || displayLevel0) {
virtualPath = "${G}";
currDir = "${G}";
parseDir (p2, virtualPath, currDir, 0, 0, displayLevel0);

View File

@@ -107,7 +107,6 @@ void Options::updatePaths()
}
if (checkDirPath (profilePath, "Error: the specified user's profiles' path doesn't point to a directory or doesn't exist!\n")) {
if (multiUser) {
userProfilePath = profilePath;
tmpPath = Glib::build_filename (argv0, "profiles");
@@ -116,9 +115,6 @@ void Options::updatePaths()
globalProfilePath = tmpPath;
}
}
} else {
globalProfilePath = profilePath;
}
} else {
tmpPath = Glib::build_filename (argv0, "profiles");
@@ -128,7 +124,6 @@ void Options::updatePaths()
}
} else {
// relative paths
if (multiUser) {
tmpPath = Glib::build_filename (rtdir, profilePath);
if (!checkDirPath (tmpPath, "")) {
@@ -148,15 +143,6 @@ void Options::updatePaths()
if (checkDirPath (tmpPath, "Error: the specified user's profiles' path doesn't point to a directory or doesn't exist!\n")) {
globalProfilePath = tmpPath;
}
} else {
// common directory
// directory name set in options is ignored, we use the default directory name
tmpPath = Glib::build_filename (argv0, "profiles");
if (checkDirPath (tmpPath, "Error: no global profiles' directory found!\n")) {
globalProfilePath = tmpPath;
}
}
}
Glib::ustring preferredPath = getPreferredProfilePath();
@@ -2133,7 +2119,7 @@ void Options::load (bool lightweight)
}
// Set the cache folder in RT's base folder
cacheBaseDir = Glib::build_filename (argv0, "cache");
cacheBaseDir = Glib::build_filename (argv0, "mycache");
// Read the global option file (the one located in the application's base folder)
try {
@@ -2142,6 +2128,10 @@ void Options::load (bool lightweight)
// ignore errors here
}
if (!options.multiUser && path == nullptr) {
rtdir = Glib::build_filename (argv0, "mysettings");
}
// Modify the path of the cache folder to the one provided in RT_CACHE environment variable
path = g_getenv ("RT_CACHE");
@@ -2153,7 +2143,7 @@ void Options::load (bool lightweight)
throw Error (msg);
}
}
// No environment variable provided, so falling back to the multi user mode, is enabled
// No environment variable provided, so falling back to the multi user mode, if enabled
else if (options.multiUser) {
#ifdef WIN32
cacheBaseDir = Glib::build_filename (rtdir, "cache");
@@ -2162,8 +2152,6 @@ void Options::load (bool lightweight)
#endif
}
// Check if RT is installed in Multi-User mode
if (options.multiUser) {
// Read the user option file (the one located somewhere in the user's home folder)
// Those values supersets those of the global option file
try {
@@ -2177,10 +2165,11 @@ void Options::load (bool lightweight)
}
#ifdef __APPLE__
if (options.multiUser) {
// make sure .local/share exists on OS X so we don't get problems with recently-used.xbel
g_mkdir_with_parents (g_get_user_data_dir(), 511);
#endif
}
#endif
if (options.rtSettings.verbose) {
printf ("Cache directory (cacheBaseDir) = %s\n", cacheBaseDir.c_str());
@@ -2275,11 +2264,7 @@ void Options::load (bool lightweight)
void Options::save ()
{
if (!options.multiUser) {
options.saveToFile (Glib::build_filename (argv0, "options"));
} else {
options.saveToFile (Glib::build_filename (rtdir, "options"));
}
}
/*