2021-01-29 20:45:11 +02:00
|
|
|
const BaseSyncTarget = require('./BaseSyncTarget').default;
|
2020-11-05 18:58:23 +02:00
|
|
|
const { _ } = require('./locale');
|
|
|
|
const Setting = require('./models/Setting').default;
|
|
|
|
const { FileApi } = require('./file-api.js');
|
2022-07-10 16:26:24 +02:00
|
|
|
const { FileApiDriverLocal } = require('./file-api-driver-local');
|
2020-11-05 18:58:23 +02:00
|
|
|
const Synchronizer = require('./Synchronizer').default;
|
2017-11-24 20:37:40 +02:00
|
|
|
|
2017-11-24 21:09:15 +02:00
|
|
|
class SyncTargetFilesystem extends BaseSyncTarget {
|
2017-11-24 20:59:16 +02:00
|
|
|
static id() {
|
2017-11-24 20:37:40 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2017-11-24 21:21:30 +02:00
|
|
|
static targetName() {
|
|
|
|
return 'filesystem';
|
|
|
|
}
|
|
|
|
|
2017-11-24 20:59:16 +02:00
|
|
|
static label() {
|
2017-11-24 20:37:40 +02:00
|
|
|
return _('File system');
|
|
|
|
}
|
|
|
|
|
2020-02-08 13:59:19 +02:00
|
|
|
static unsupportedPlatforms() {
|
|
|
|
return ['ios'];
|
|
|
|
}
|
|
|
|
|
2018-03-26 19:33:55 +02:00
|
|
|
async isAuthenticated() {
|
2017-11-24 20:37:40 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-24 20:59:16 +02:00
|
|
|
async initFileApi() {
|
2018-01-17 23:01:41 +02:00
|
|
|
const syncPath = Setting.value('sync.2.path');
|
|
|
|
const driver = new FileApiDriverLocal();
|
|
|
|
const fileApi = new FileApi(syncPath, driver);
|
2017-11-24 20:37:40 +02:00
|
|
|
fileApi.setLogger(this.logger());
|
2017-11-24 21:09:15 +02:00
|
|
|
fileApi.setSyncTargetId(SyncTargetFilesystem.id());
|
2018-01-17 23:01:41 +02:00
|
|
|
await driver.mkdir(syncPath);
|
2017-11-24 20:37:40 +02:00
|
|
|
return fileApi;
|
|
|
|
}
|
|
|
|
|
|
|
|
async initSynchronizer() {
|
2017-11-24 20:59:16 +02:00
|
|
|
return new Synchronizer(this.db(), await this.fileApi(), Setting.value('appType'));
|
2017-11-24 20:37:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-29 15:43:53 +02:00
|
|
|
module.exports = SyncTargetFilesystem;
|