You've already forked joplin
							
							
				mirror of
				https://github.com/laurent22/joplin.git
				synced 2025-10-31 00:07:48 +02:00 
			
		
		
		
	iOS: Fixes #2301: Removed filesystem sync option, which was not supported
This commit is contained in:
		
							
								
								
									
										11
									
								
								ElectronClient/app/envFromArgs.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								ElectronClient/app/envFromArgs.js
									
									
									
									
									
										Normal 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; | ||||
| @@ -8,22 +8,13 @@ const { ElectronAppWrapper } = require('./ElectronAppWrapper'); | ||||
| const { initBridge } = require('./bridge'); | ||||
| const { Logger } = require('lib/logger.js'); | ||||
| const { FsDriverNode } = require('lib/fs-driver-node.js'); | ||||
| const envFromArgs = require('./envFromArgs'); | ||||
|  | ||||
| process.on('unhandledRejection', (reason, p) => { | ||||
| 	console.error('Unhandled promise rejection', p, 'reason:', reason); | ||||
| 	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 | ||||
| // to save the window state data. | ||||
| function profileFromArgs(args) { | ||||
|   | ||||
| @@ -40,13 +40,6 @@ const SearchEngine = require('lib/services/SearchEngine'); | ||||
| const KvStore = require('lib/services/KvStore'); | ||||
| 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 { | ||||
| 	constructor() { | ||||
| 		this.logger_ = new Logger(); | ||||
| @@ -580,6 +573,13 @@ class BaseApplication { | ||||
| 		Setting.setConstant('resourceDir', resourceDir); | ||||
| 		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 fs.mkdirp(profileDir, 0o755); | ||||
|   | ||||
| @@ -33,6 +33,11 @@ class BaseSyncTarget { | ||||
| 		return this.db_; | ||||
| 	} | ||||
|  | ||||
| 	// If [] is returned it means all platforms are supported | ||||
| 	static unsupportedPlatforms() { | ||||
| 		return []; | ||||
| 	} | ||||
|  | ||||
| 	async isAuthenticated() { | ||||
| 		return false; | ||||
| 	} | ||||
|   | ||||
| @@ -18,6 +18,10 @@ class SyncTargetFilesystem extends BaseSyncTarget { | ||||
| 		return _('File system'); | ||||
| 	} | ||||
|  | ||||
| 	static unsupportedPlatforms() { | ||||
| 		return ['ios']; | ||||
| 	} | ||||
|  | ||||
| 	async isAuthenticated() { | ||||
| 		return true; | ||||
| 	} | ||||
|   | ||||
| @@ -35,11 +35,15 @@ class SyncTargetRegistry { | ||||
| 		return this.idToMetadata(id).name; | ||||
| 	} | ||||
|  | ||||
| 	static idAndLabelPlainObject() { | ||||
| 	static idAndLabelPlainObject(os) { | ||||
| 		let output = {}; | ||||
| 		for (let n in this.reg_) { | ||||
| 			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; | ||||
| 	} | ||||
|   | ||||
| @@ -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).'); | ||||
| 				}, | ||||
| 				options: () => { | ||||
| 					return SyncTargetRegistry.idAndLabelPlainObject(); | ||||
| 					return SyncTargetRegistry.idAndLabelPlainObject(platform); | ||||
| 				}, | ||||
| 			}, | ||||
|  | ||||
|   | ||||
| @@ -33,7 +33,7 @@ shim.isMac = () => { | ||||
| }; | ||||
|  | ||||
| shim.platformName = function() { | ||||
| 	if (shim.isReactNative()) return 'mobile'; | ||||
| 	if (shim.isReactNative()) return shim.mobilePlatform(); | ||||
| 	if (shim.isMac()) return 'darwin'; | ||||
| 	if (shim.isWindows()) return 'win32'; | ||||
| 	if (shim.isLinux()) return 'linux'; | ||||
|   | ||||
| @@ -70,8 +70,9 @@ const SyncTargetOneDriveDev = require('lib/SyncTargetOneDriveDev.js'); | ||||
| const SyncTargetNextcloud = require('lib/SyncTargetNextcloud.js'); | ||||
| const SyncTargetWebDAV = require('lib/SyncTargetWebDAV.js'); | ||||
| const SyncTargetDropbox = require('lib/SyncTargetDropbox.js'); | ||||
|  | ||||
| SyncTargetRegistry.addClass(SyncTargetOneDrive); | ||||
| SyncTargetRegistry.addClass(SyncTargetOneDriveDev); | ||||
| if (__DEV__) SyncTargetRegistry.addClass(SyncTargetOneDriveDev); | ||||
| SyncTargetRegistry.addClass(SyncTargetNextcloud); | ||||
| SyncTargetRegistry.addClass(SyncTargetWebDAV); | ||||
| SyncTargetRegistry.addClass(SyncTargetDropbox); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user