1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Desktop: Fixes #6459: Sync config was lost when switching profiles

This commit is contained in:
Laurent Cozic
2022-05-05 18:15:10 +01:00
parent 27118c2d00
commit 191c49c0cd
3 changed files with 40 additions and 4 deletions

View File

@ -255,6 +255,10 @@ async function afterAllCleanUp() {
}
}
const settingFilename = (id: number): string => {
return `settings-${id}.json`;
};
async function switchClient(id: number, options: any = null) {
options = Object.assign({}, { keychainEnabled: false }, options);
@ -271,18 +275,19 @@ async function switchClient(id: number, options: any = null) {
BaseItem.revisionService_ = revisionServices_[id];
await Setting.reset();
Setting.settingFilename = `settings-${id}.json`;
Setting.settingFilename = settingFilename(id);
Setting.setConstant('profileDir', rootProfileDir);
Setting.setConstant('rootProfileDir', rootProfileDir);
Setting.setConstant('resourceDirName', resourceDirName(id));
Setting.setConstant('resourceDir', resourceDir(id));
Setting.setConstant('pluginDir', pluginDir(id));
Setting.setConstant('isSubProfile', false);
await loadKeychainServiceAndSettings(options.keychainEnabled ? KeychainServiceDriver : KeychainServiceDriverDummy);
Setting.setValue('sync.target', syncTargetId());
Setting.setValue('sync.wipeOutFailSafe', false); // To keep things simple, always disable fail-safe unless explicitely set in the test itself
Setting.setValue('sync.wipeOutFailSafe', false); // To keep things simple, always disable fail-safe unless explicitly set in the test itself
// More generally, this function should clear all data, and so that should
// include settings.json
@ -336,6 +341,7 @@ async function setupDatabase(id: number = null, options: any = null) {
Setting.setConstant('profileDir', rootProfileDir);
Setting.setConstant('rootProfileDir', rootProfileDir);
Setting.setConstant('isSubProfile', false);
if (databases_[id]) {
BaseModel.setDb(databases_[id]);