Skip to content

frontend: Use default location for user settings as fallback #12040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions frontend/OBSApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ bool OBSApp::InitGlobalConfig()

uint32_t lastVersion = config_get_int(appConfig, "General", "LastVersion");

if (lastVersion < MAKE_SEMANTIC_VERSION(31, 0, 0)) {
if (lastVersion && lastVersion < MAKE_SEMANTIC_VERSION(31, 0, 0)) {
bool migratedUserSettings = config_get_bool(appConfig, "General", "Pre31Migrated");

if (!migratedUserSettings) {
Expand All @@ -445,19 +445,34 @@ bool OBSApp::InitGlobalConfig()
InitGlobalConfigDefaults();
InitGlobalLocationDefaults();

std::filesystem::path defaultUserConfigLocation =
std::filesystem::u8path(config_get_default_string(appConfig, "Locations", "Configuration"));
std::filesystem::path defaultUserScenesLocation =
std::filesystem::u8path(config_get_default_string(appConfig, "Locations", "SceneCollections"));
std::filesystem::path defaultUserProfilesLocation =
std::filesystem::u8path(config_get_default_string(appConfig, "Locations", "Profiles"));

if (IsPortableMode()) {
userConfigLocation =
std::filesystem::u8path(config_get_default_string(appConfig, "Locations", "Configuration"));
userScenesLocation =
std::filesystem::u8path(config_get_default_string(appConfig, "Locations", "SceneCollections"));
userProfilesLocation =
std::filesystem::u8path(config_get_default_string(appConfig, "Locations", "Profiles"));
userConfigLocation = std::move(defaultUserConfigLocation);
userScenesLocation = std::move(defaultUserScenesLocation);
userProfilesLocation = std::move(defaultUserProfilesLocation);
} else {
userConfigLocation =
std::filesystem::path currentUserConfigLocation =
std::filesystem::u8path(config_get_string(appConfig, "Locations", "Configuration"));
userScenesLocation =
std::filesystem::path currentUserScenesLocation =
std::filesystem::u8path(config_get_string(appConfig, "Locations", "SceneCollections"));
userProfilesLocation = std::filesystem::u8path(config_get_string(appConfig, "Locations", "Profiles"));
std::filesystem::path currentUserProfilesLocation =
std::filesystem::u8path(config_get_string(appConfig, "Locations", "Profiles"));

userConfigLocation = (std::filesystem::exists(currentUserConfigLocation))
? std::move(currentUserConfigLocation)
: std::move(defaultUserConfigLocation);
userScenesLocation = (std::filesystem::exists(currentUserScenesLocation))
? std::move(currentUserScenesLocation)
: std::move(defaultUserScenesLocation);
userProfilesLocation = (std::filesystem::exists(currentUserProfilesLocation))
? std::move(currentUserProfilesLocation)
: std::move(defaultUserProfilesLocation);
}

bool userConfigResult = InitUserConfig(userConfigLocation, lastVersion);
Expand Down
Loading