forked from laurent22/joplin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All: Started moving sync target logic under SyncTarget classes
- Loading branch information
Showing
7 changed files
with
117 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const BaseSyncTarget = require('lib/BaseSyncTarget.js'); | ||
const { _ } = require('lib/locale.js'); | ||
const { Setting } = require('lib/models/setting.js'); | ||
const { FileApi } = require('lib/file-api.js'); | ||
const { FileApiDriverLocal } = require('lib/file-api-driver-local.js'); | ||
const { Synchronizer } = require('lib/synchronizer.js'); | ||
|
||
class SyncTarget2 extends BaseSyncTarget { | ||
|
||
id() { | ||
return 2; | ||
} | ||
|
||
name() { | ||
return 'filesystem'; | ||
} | ||
|
||
label() { | ||
return _('File system'); | ||
} | ||
|
||
isAuthenticated() { | ||
return true; | ||
} | ||
|
||
initFileApi() { | ||
const fileApi = new FileApi(Setting.value('sync.2.path'), new FileApiDriverLocal()); | ||
fileApi.setLogger(this.logger()); | ||
fileApi.setSyncTargetId(this.id()); | ||
return fileApi; | ||
} | ||
|
||
async initSynchronizer() { | ||
return new Synchronizer(this.db(), this.fileApi(), Setting.value('appType')); | ||
} | ||
|
||
} | ||
|
||
module.exports = SyncTarget2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const syncTargetClasses_ = { | ||
1: require('lib/SyncTarget1.js'), | ||
2: require('lib/SyncTarget2.js'), | ||
3: require('lib/SyncTarget3.js'), | ||
}; | ||
|
||
class SyncTargetRegistry { | ||
|
||
static classById(syncTargetId) { | ||
if (!syncTargetClasses_[syncTargetId]) throw new Error('Invalid id: ' + syncTargetId); | ||
return syncTargetClasses_[syncTargetId]; | ||
} | ||
|
||
} | ||
|
||
module.exports = SyncTargetRegistry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters