1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-13 00:10:37 +02:00

iOS: Fixes #2301: Removed filesystem sync option, which was not supported

This commit is contained in:
Laurent Cozic
2020-02-08 11:59:19 +00:00
parent 1606076b4e
commit 0229686203
9 changed files with 38 additions and 22 deletions

View File

@ -0,0 +1,11 @@
// Flags are parsed properly in BaseApplication, however it's better to have
// the env as early as possible to enable debugging capabilities.
function envFromArgs(args) {
if (!args) return 'prod';
const envIndex = args.indexOf('--env');
const devIndex = args.indexOf('dev');
if (envIndex === devIndex - 1) return 'dev';
return 'prod';
}
module.exports = envFromArgs;

View File

@ -8,22 +8,13 @@ const { ElectronAppWrapper } = require('./ElectronAppWrapper');
const { initBridge } = require('./bridge'); const { initBridge } = require('./bridge');
const { Logger } = require('lib/logger.js'); const { Logger } = require('lib/logger.js');
const { FsDriverNode } = require('lib/fs-driver-node.js'); const { FsDriverNode } = require('lib/fs-driver-node.js');
const envFromArgs = require('./envFromArgs');
process.on('unhandledRejection', (reason, p) => { process.on('unhandledRejection', (reason, p) => {
console.error('Unhandled promise rejection', p, 'reason:', reason); console.error('Unhandled promise rejection', p, 'reason:', reason);
process.exit(1); process.exit(1);
}); });
// Flags are parsed properly in BaseApplication, however it's better to have
// the env as early as possible to enable debugging capabilities.
function envFromArgs(args) {
if (!args) return 'prod';
const envIndex = args.indexOf('--env');
const devIndex = args.indexOf('dev');
if (envIndex === devIndex - 1) return 'dev';
return 'prod';
}
// Likewise, we want to know if a profile is specified early, in particular // Likewise, we want to know if a profile is specified early, in particular
// to save the window state data. // to save the window state data.
function profileFromArgs(args) { function profileFromArgs(args) {

View File

@ -40,13 +40,6 @@ const SearchEngine = require('lib/services/SearchEngine');
const KvStore = require('lib/services/KvStore'); const KvStore = require('lib/services/KvStore');
const MigrationService = require('lib/services/MigrationService'); const MigrationService = require('lib/services/MigrationService');
SyncTargetRegistry.addClass(SyncTargetFilesystem);
SyncTargetRegistry.addClass(SyncTargetOneDrive);
SyncTargetRegistry.addClass(SyncTargetOneDriveDev);
SyncTargetRegistry.addClass(SyncTargetNextcloud);
SyncTargetRegistry.addClass(SyncTargetWebDAV);
SyncTargetRegistry.addClass(SyncTargetDropbox);
class BaseApplication { class BaseApplication {
constructor() { constructor() {
this.logger_ = new Logger(); this.logger_ = new Logger();
@ -580,6 +573,13 @@ class BaseApplication {
Setting.setConstant('resourceDir', resourceDir); Setting.setConstant('resourceDir', resourceDir);
Setting.setConstant('tempDir', tempDir); Setting.setConstant('tempDir', tempDir);
SyncTargetRegistry.addClass(SyncTargetFilesystem);
SyncTargetRegistry.addClass(SyncTargetOneDrive);
if (Setting.value('env') === 'dev') SyncTargetRegistry.addClass(SyncTargetOneDriveDev);
SyncTargetRegistry.addClass(SyncTargetNextcloud);
SyncTargetRegistry.addClass(SyncTargetWebDAV);
SyncTargetRegistry.addClass(SyncTargetDropbox);
await shim.fsDriver().remove(tempDir); await shim.fsDriver().remove(tempDir);
await fs.mkdirp(profileDir, 0o755); await fs.mkdirp(profileDir, 0o755);

View File

@ -33,6 +33,11 @@ class BaseSyncTarget {
return this.db_; return this.db_;
} }
// If [] is returned it means all platforms are supported
static unsupportedPlatforms() {
return [];
}
async isAuthenticated() { async isAuthenticated() {
return false; return false;
} }

View File

@ -18,6 +18,10 @@ class SyncTargetFilesystem extends BaseSyncTarget {
return _('File system'); return _('File system');
} }
static unsupportedPlatforms() {
return ['ios'];
}
async isAuthenticated() { async isAuthenticated() {
return true; return true;
} }

View File

@ -35,11 +35,15 @@ class SyncTargetRegistry {
return this.idToMetadata(id).name; return this.idToMetadata(id).name;
} }
static idAndLabelPlainObject() { static idAndLabelPlainObject(os) {
let output = {}; let output = {};
for (let n in this.reg_) { for (let n in this.reg_) {
if (!this.reg_.hasOwnProperty(n)) continue; if (!this.reg_.hasOwnProperty(n)) continue;
output[n] = this.reg_[n].label; const info = this.reg_[n];
if (info.classRef.unsupportedPlatforms().indexOf(os) >= 0) {
continue;
}
output[n] = info.label;
} }
return output; return output;
} }

View File

@ -62,7 +62,7 @@ class Setting extends BaseModel {
return appType !== 'cli' ? null : _('The target to synchonise to. Each sync target may have additional parameters which are named as `sync.NUM.NAME` (all documented below).'); return appType !== 'cli' ? null : _('The target to synchonise to. Each sync target may have additional parameters which are named as `sync.NUM.NAME` (all documented below).');
}, },
options: () => { options: () => {
return SyncTargetRegistry.idAndLabelPlainObject(); return SyncTargetRegistry.idAndLabelPlainObject(platform);
}, },
}, },

View File

@ -33,7 +33,7 @@ shim.isMac = () => {
}; };
shim.platformName = function() { shim.platformName = function() {
if (shim.isReactNative()) return 'mobile'; if (shim.isReactNative()) return shim.mobilePlatform();
if (shim.isMac()) return 'darwin'; if (shim.isMac()) return 'darwin';
if (shim.isWindows()) return 'win32'; if (shim.isWindows()) return 'win32';
if (shim.isLinux()) return 'linux'; if (shim.isLinux()) return 'linux';

View File

@ -70,8 +70,9 @@ const SyncTargetOneDriveDev = require('lib/SyncTargetOneDriveDev.js');
const SyncTargetNextcloud = require('lib/SyncTargetNextcloud.js'); const SyncTargetNextcloud = require('lib/SyncTargetNextcloud.js');
const SyncTargetWebDAV = require('lib/SyncTargetWebDAV.js'); const SyncTargetWebDAV = require('lib/SyncTargetWebDAV.js');
const SyncTargetDropbox = require('lib/SyncTargetDropbox.js'); const SyncTargetDropbox = require('lib/SyncTargetDropbox.js');
SyncTargetRegistry.addClass(SyncTargetOneDrive); SyncTargetRegistry.addClass(SyncTargetOneDrive);
SyncTargetRegistry.addClass(SyncTargetOneDriveDev); if (__DEV__) SyncTargetRegistry.addClass(SyncTargetOneDriveDev);
SyncTargetRegistry.addClass(SyncTargetNextcloud); SyncTargetRegistry.addClass(SyncTargetNextcloud);
SyncTargetRegistry.addClass(SyncTargetWebDAV); SyncTargetRegistry.addClass(SyncTargetWebDAV);
SyncTargetRegistry.addClass(SyncTargetDropbox); SyncTargetRegistry.addClass(SyncTargetDropbox);