1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-14 18:27:44 +02:00

Desktop,Mobile,Cli: Fixes #9800: Fix synchronization happens every 10 seconds even if nothing has changed (#9814)

This commit is contained in:
Henry Heino 2024-02-02 09:53:22 -08:00 committed by GitHub
parent 7c539976dd
commit 236d977c41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View File

@ -105,6 +105,15 @@ describe('syncInfoUtils', () => {
syncInfo1.appMinVersion = '1.0.0';
syncInfo2.appMinVersion = '1.0.0';
expect(mergeSyncInfos(syncInfo1, syncInfo2).appMinVersion).toBe('1.0.0');
// Should prefer the version from syncInfo1 if versions are otherwise equal.
syncInfo1.appMinVersion = '1.00';
syncInfo2.appMinVersion = '1.0.0';
expect(mergeSyncInfos(syncInfo1, syncInfo2).appMinVersion).toBe('1.00');
syncInfo1.appMinVersion = '0.0.0';
syncInfo2.appMinVersion = '0.00';
expect(mergeSyncInfos(syncInfo1, syncInfo2).appMinVersion).toBe('0.0.0');
});
it('should merge sync target info and takes into account usage of master key - 1', async () => {

View File

@ -178,6 +178,7 @@ const mergeActiveMasterKeys = (s1: SyncInfo, s2: SyncInfo, output: SyncInfo) =>
}
};
// If there is a distinction, s1 should be local sync info and s2 remote.
export function mergeSyncInfos(s1: SyncInfo, s2: SyncInfo): SyncInfo {
const output: SyncInfo = new SyncInfo();
@ -199,7 +200,10 @@ export function mergeSyncInfos(s1: SyncInfo, s2: SyncInfo): SyncInfo {
}
}
output.appMinVersion = compareVersions(s1.appMinVersion, s2.appMinVersion) > 0 ? s1.appMinVersion : s2.appMinVersion;
// We use >= so that the version from s1 (local) is preferred to the version in s2 (remote).
// For example, if s2 has appMinVersion 0.00 and s1 has appMinVersion 0.0.0, we choose the
// local version, 0.0.0.
output.appMinVersion = compareVersions(s1.appMinVersion, s2.appMinVersion) >= 0 ? s1.appMinVersion : s2.appMinVersion;
return output;
}
@ -247,7 +251,7 @@ export class SyncInfo {
this.activeMasterKeyId_ = 'activeMasterKeyId' in s ? s.activeMasterKeyId : { value: '', updatedTime: 0 };
this.masterKeys_ = 'masterKeys' in s ? s.masterKeys : [];
this.ppk_ = 'ppk' in s ? s.ppk : { value: null, updatedTime: 0 };
this.appMinVersion_ = s.appMinVersion ? s.appMinVersion : '0.00';
this.appMinVersion_ = s.appMinVersion ? s.appMinVersion : '0.0.0';
// Migration for master keys that didn't have "hasBeenUsed" property -
// in that case we assume they've been used at least once.