mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-01-30 12:32:43 +00:00
Only attempt a config migration once per launch
This commit is contained in:
parent
aa1985dec8
commit
8c9e14e335
@ -106,12 +106,16 @@ namespace platf {
|
|||||||
*/
|
*/
|
||||||
fs::path
|
fs::path
|
||||||
appdata() {
|
appdata() {
|
||||||
|
static std::once_flag migration_flag;
|
||||||
|
static fs::path config_path;
|
||||||
|
|
||||||
|
// Ensure migration is only attempted once
|
||||||
|
std::call_once(migration_flag, []() {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
bool migrate_config = true;
|
bool migrate_config = true;
|
||||||
const char *dir;
|
const char *dir;
|
||||||
const char *homedir;
|
const char *homedir;
|
||||||
const char *migrate_envvar;
|
const char *migrate_envvar;
|
||||||
fs::path config_path;
|
|
||||||
|
|
||||||
// Get the home directory
|
// Get the home directory
|
||||||
if ((homedir = getenv("HOME")) == nullptr || strlen(homedir) == 0) {
|
if ((homedir = getenv("HOME")) == nullptr || strlen(homedir) == 0) {
|
||||||
@ -147,7 +151,7 @@ namespace platf {
|
|||||||
fs::rename(old_config_path, config_path, ec);
|
fs::rename(old_config_path, config_path, ec);
|
||||||
if (ec) {
|
if (ec) {
|
||||||
std::cerr << "Migration failed: " << ec.message() << std::endl;
|
std::cerr << "Migration failed: " << ec.message() << std::endl;
|
||||||
return old_config_path;
|
config_path = old_config_path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -157,6 +161,7 @@ namespace platf {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return config_path;
|
return config_path;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user