mirror of
https://github.com/laurent22/joplin.git
synced 2025-03-11 14:09:55 +02:00
All: Fixed issue that could cause application to needlessly lock the sync target
This commit is contained in:
parent
7c3785e89d
commit
0de6e9ed11
1
packages/lib/package-lock.json
generated
1
packages/lib/package-lock.json
generated
@ -20,6 +20,7 @@
|
||||
"css": "^3.0.0",
|
||||
"diff-match-patch": "^1.0.4",
|
||||
"es6-promise-pool": "^2.5.0",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"file-uri-to-path": "^1.0.0",
|
||||
"follow-redirects": "^1.2.4",
|
||||
"form-data": "^2.1.4",
|
||||
|
@ -44,6 +44,7 @@
|
||||
"css": "^3.0.0",
|
||||
"diff-match-patch": "^1.0.4",
|
||||
"es6-promise-pool": "^2.5.0",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"file-uri-to-path": "^1.0.0",
|
||||
"follow-redirects": "^1.2.4",
|
||||
"form-data": "^2.1.4",
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { afterAllCleanUp, setupDatabaseAndSynchronizer, switchClient, encryptionService } from '../../testing/test-utils';
|
||||
import MasterKey from '../../models/MasterKey';
|
||||
import { masterKeyEnabled, setMasterKeyEnabled } from './syncInfoUtils';
|
||||
import { masterKeyEnabled, setMasterKeyEnabled, SyncInfo, syncInfoEquals } from './syncInfoUtils';
|
||||
|
||||
describe('syncInfoUtils', function() {
|
||||
|
||||
@ -34,4 +34,62 @@ describe('syncInfoUtils', function() {
|
||||
expect(masterKeyEnabled(await MasterKey.load(mk2.id))).toBe(false);
|
||||
});
|
||||
|
||||
it('should tell if two sync info are equal', async () => {
|
||||
{
|
||||
const syncInfo1 = new SyncInfo();
|
||||
const syncInfo2 = new SyncInfo();
|
||||
expect(syncInfoEquals(syncInfo1, syncInfo2)).toBe(true);
|
||||
}
|
||||
|
||||
{
|
||||
const syncInfo1 = new SyncInfo();
|
||||
syncInfo1.masterKeys = [{
|
||||
id: 'id',
|
||||
content: 'content',
|
||||
}];
|
||||
|
||||
const syncInfo2 = new SyncInfo();
|
||||
syncInfo2.masterKeys = [{
|
||||
id: 'id',
|
||||
content: 'different',
|
||||
}];
|
||||
|
||||
expect(syncInfoEquals(syncInfo1, syncInfo2)).toBe(false);
|
||||
}
|
||||
|
||||
{
|
||||
const syncInfo1 = new SyncInfo();
|
||||
syncInfo1.masterKeys = [{
|
||||
id: 'id',
|
||||
content: 'content',
|
||||
}];
|
||||
|
||||
const syncInfo2 = new SyncInfo();
|
||||
syncInfo2.masterKeys = [{
|
||||
id: 'id',
|
||||
content: 'content',
|
||||
}];
|
||||
|
||||
expect(syncInfoEquals(syncInfo1, syncInfo2)).toBe(true);
|
||||
}
|
||||
|
||||
{
|
||||
// Should disregard object key order
|
||||
|
||||
const syncInfo1 = new SyncInfo();
|
||||
syncInfo1.masterKeys = [{
|
||||
content: 'content',
|
||||
id: 'id',
|
||||
}];
|
||||
|
||||
const syncInfo2 = new SyncInfo();
|
||||
syncInfo2.masterKeys = [{
|
||||
id: 'id',
|
||||
content: 'content',
|
||||
}];
|
||||
|
||||
expect(syncInfoEquals(syncInfo1, syncInfo2)).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -4,6 +4,7 @@ import Setting from '../../models/Setting';
|
||||
import { State } from '../../reducer';
|
||||
import { PublicPrivateKeyPair } from '../e2ee/ppk';
|
||||
import { MasterKeyEntity } from '../e2ee/types';
|
||||
const fastDeepEqual = require('fast-deep-equal');
|
||||
|
||||
export interface SyncInfoValueBoolean {
|
||||
value: boolean;
|
||||
@ -113,7 +114,7 @@ export function mergeSyncInfos(s1: SyncInfo, s2: SyncInfo): SyncInfo {
|
||||
}
|
||||
|
||||
export function syncInfoEquals(s1: SyncInfo, s2: SyncInfo): boolean {
|
||||
return s1.serialize() === s2.serialize();
|
||||
return fastDeepEqual(s1.toObject(), s2.toObject());
|
||||
}
|
||||
|
||||
export class SyncInfo {
|
||||
|
Loading…
x
Reference in New Issue
Block a user