You've already forked joplin
							
							
				mirror of
				https://github.com/laurent22/joplin.git
				synced 2025-10-31 00:07:48 +02:00 
			
		
		
		
	Chore: Change the return type of shim.fsDriver() from any to FsDriverBase (#9460)
				
					
				
			This commit is contained in:
		| @@ -50,7 +50,7 @@ export default class InteropServiceHelper { | ||||
|  | ||||
| 		const cleanup = () => { | ||||
| 			if (win) win.destroy(); | ||||
| 			if (htmlFile) shim.fsDriver().remove(htmlFile); | ||||
| 			if (htmlFile) void shim.fsDriver().remove(htmlFile); | ||||
| 		}; | ||||
|  | ||||
| 		try { | ||||
| @@ -67,7 +67,7 @@ export default class InteropServiceHelper { | ||||
|  | ||||
| 			win = bridge().newBrowserWindow(windowOptions); | ||||
|  | ||||
| 			return new Promise((resolve, reject) => { | ||||
| 			return new Promise<any>((resolve, reject) => { | ||||
| 				win.webContents.on('did-finish-load', () => { | ||||
|  | ||||
| 					// did-finish-load will trigger when most assets are done loading, probably | ||||
|   | ||||
| @@ -301,12 +301,8 @@ export default class FsDriverRN extends FsDriverBase { | ||||
| 		return output ? output : null; | ||||
| 	} | ||||
|  | ||||
| 	public resolve(path: string) { | ||||
| 		throw new Error(`Not implemented: resolve(): ${path}`); | ||||
| 	} | ||||
|  | ||||
| 	public resolveRelativePathWithinDir(_baseDir: string, relativePath: string) { | ||||
| 		throw new Error(`Not implemented: resolveRelativePathWithinDir(): ${relativePath}`); | ||||
| 	public resolve(...paths: string[]): string { | ||||
| 		throw new Error(`Not implemented: resolve(): ${JSON.stringify(paths)}`); | ||||
| 	} | ||||
|  | ||||
| 	public async md5File(path: string): Promise<string> { | ||||
|   | ||||
| @@ -4,8 +4,8 @@ import { filename, fileExtension } from './path-utils'; | ||||
| const md5 = require('md5'); | ||||
|  | ||||
| export interface Stat { | ||||
| 	birthtime: number; | ||||
| 	mtime: number; | ||||
| 	birthtime: Date; | ||||
| 	mtime: Date; | ||||
| 	isDirectory(): boolean; | ||||
| 	path: string; | ||||
| 	size: number; | ||||
| @@ -49,6 +49,10 @@ export default class FsDriverBase { | ||||
| 		throw new Error('Not implemented'); | ||||
| 	} | ||||
|  | ||||
| 	public async rename(source: string, dest: string) { | ||||
| 		return this.move(source, dest); | ||||
| 	} | ||||
|  | ||||
| 	public async readFileChunk(_handle: any, _length: number, _encoding = 'base64'): Promise<string> { | ||||
| 		throw new Error('Not implemented'); | ||||
| 	} | ||||
| @@ -82,6 +86,26 @@ export default class FsDriverBase { | ||||
| 		throw new Error('Not implemented'); | ||||
| 	} | ||||
|  | ||||
| 	public async md5File(_path: string): Promise<string> { | ||||
| 		throw new Error('Not implemented: md5File'); | ||||
| 	} | ||||
|  | ||||
| 	public resolve(..._paths: string[]): string { | ||||
| 		throw new Error('Not implemented: resolve'); | ||||
| 	} | ||||
|  | ||||
| 	public resolveRelativePathWithinDir(_baseDir: string, relativePath: string): string { | ||||
| 		throw new Error(`Not implemented: resolveRelativePathWithinDir(): ${relativePath}`); | ||||
| 	} | ||||
|  | ||||
| 	public getExternalDirectoryPath(): Promise<string | undefined> { | ||||
| 		throw new Error('Not implemented: getExternalDirectoryPath'); | ||||
| 	} | ||||
|  | ||||
| 	public isUsingAndroidSAF() { | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	protected async readDirStatsHandleRecursion_(basePath: string, stat: Stat, output: Stat[], options: ReadDirStatsOptions): Promise<Stat[]> { | ||||
| 		if (options.recursive && stat.isDirectory()) { | ||||
| 			const subPath = `${basePath}/${stat.path}`; | ||||
|   | ||||
| @@ -31,8 +31,8 @@ export async function installDefaultPlugins(service: PluginService, defaultPlugi | ||||
|  | ||||
| 	const installedPlugins = Setting.value('installedDefaultPlugins'); | ||||
|  | ||||
| 	for (let pluginId of defaultPluginsPaths) { | ||||
| 		pluginId = pluginId.path; | ||||
| 	for (const pluginStat of defaultPluginsPaths) { | ||||
| 		const pluginId = pluginStat.path; | ||||
|  | ||||
| 		// if pluginId is present in 'installedDefaultPlugins' array or it doesn't have default plugin ID, then we won't install it again as default plugin | ||||
| 		if (installedPlugins.includes(pluginId) || !defaultPluginsId.includes(pluginId)) continue; | ||||
|   | ||||
| @@ -38,7 +38,7 @@ describe('routes/notes', () => { | ||||
| 		jest.spyOn(shim, 'fsDriver').mockImplementation(() => { | ||||
| 			return { | ||||
| 				copy: fsDriverCopySpy, | ||||
| 			}; | ||||
| 			} as any; | ||||
| 		}); | ||||
| 		jest.spyOn(uuid, 'create').mockReturnValue('mocked_uuid_value'); | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import * as React from 'react'; | ||||
| import { NoteEntity, ResourceEntity } from './services/database/types'; | ||||
| import type FsDriverBase from './fs-driver-base'; | ||||
|  | ||||
| let isTestingEnv_ = false; | ||||
|  | ||||
| @@ -203,7 +204,7 @@ const shim = { | ||||
|  | ||||
| 	FormData: typeof FormData !== 'undefined' ? FormData : null, | ||||
|  | ||||
| 	fsDriver: (): any => { | ||||
| 	fsDriver: (): FsDriverBase => { | ||||
| 		throw new Error('Not implemented'); | ||||
| 	}, | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user