From 326fef486c77d1cf6567b9da137b8b413c3725ea Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sat, 19 Jun 2021 14:22:53 +0100 Subject: [PATCH] All: Added feature flags to disable Joplin Server sync optimisations by default, so that it still work with server 2.0 --- packages/lib/Synchronizer.ts | 2 +- packages/lib/file-api-driver-joplinServer.ts | 5 +++-- packages/lib/models/Setting.ts | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/lib/Synchronizer.ts b/packages/lib/Synchronizer.ts index 319bfcee2..70e082004 100644 --- a/packages/lib/Synchronizer.ts +++ b/packages/lib/Synchronizer.ts @@ -378,7 +378,7 @@ export default class Synchronizer { this.dispatch({ type: 'SYNC_STARTED' }); eventManager.emit('syncStart'); - this.logSyncOperation('starting', null, null, `Starting synchronisation to target ${syncTargetId}... [${synchronizationId}]`); + this.logSyncOperation('starting', null, null, `Starting synchronisation to target ${syncTargetId}... supportsAccurateTimestamp = ${this.api().supportsAccurateTimestamp}; supportsMultiPut = ${this.api().supportsMultiPut} [${synchronizationId}]`); const handleCannotSyncItem = async (ItemClass: any, syncTargetId: any, item: any, cannotSyncReason: string, itemLocation: any = null) => { await ItemClass.saveSyncDisabled(syncTargetId, item, cannotSyncReason, itemLocation); diff --git a/packages/lib/file-api-driver-joplinServer.ts b/packages/lib/file-api-driver-joplinServer.ts index 2f75526d7..c1fc89dc3 100644 --- a/packages/lib/file-api-driver-joplinServer.ts +++ b/packages/lib/file-api-driver-joplinServer.ts @@ -1,6 +1,7 @@ import { MultiPutItem } from './file-api'; import JoplinError from './JoplinError'; import JoplinServerApi from './JoplinServerApi'; +import Setting from './models/Setting'; import { trimSlashes } from './path-utils'; // All input paths should be in the format: "path/to/file". This is converted to @@ -33,11 +34,11 @@ export default class FileApiDriverJoplinServer { } public get supportsMultiPut() { - return true; + return Setting.value('featureFlag.syncMultiPut'); } public get supportsAccurateTimestamp() { - return true; + return Setting.value('featureFlag.syncAccurateTimestamps'); } public requestRepeatCount() { diff --git a/packages/lib/models/Setting.ts b/packages/lib/models/Setting.ts index f0f518a89..7bde97c7d 100644 --- a/packages/lib/models/Setting.ts +++ b/packages/lib/models/Setting.ts @@ -1242,6 +1242,21 @@ class Setting extends BaseModel { appTypes: ['desktop'], storage: SettingStorage.Database, }, + + 'featureFlag.syncAccurateTimestamps': { + value: false, + type: SettingItemType.Bool, + public: false, + storage: SettingStorage.File, + }, + + 'featureFlag.syncMultiPut': { + value: false, + type: SettingItemType.Bool, + public: false, + storage: SettingStorage.File, + }, + }; this.metadata_ = Object.assign(this.metadata_, this.customMetadata_);