1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Chore: Change the return type of shim.fsDriver() from any to FsDriverBase (#9460)

This commit is contained in:
Henry Heino 2023-12-06 11:24:00 -08:00 committed by GitHub
parent 48ea014ee0
commit d63fc524bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 14 deletions

View File

@ -50,7 +50,7 @@ export default class InteropServiceHelper {
const cleanup = () => { const cleanup = () => {
if (win) win.destroy(); if (win) win.destroy();
if (htmlFile) shim.fsDriver().remove(htmlFile); if (htmlFile) void shim.fsDriver().remove(htmlFile);
}; };
try { try {
@ -67,7 +67,7 @@ export default class InteropServiceHelper {
win = bridge().newBrowserWindow(windowOptions); win = bridge().newBrowserWindow(windowOptions);
return new Promise((resolve, reject) => { return new Promise<any>((resolve, reject) => {
win.webContents.on('did-finish-load', () => { win.webContents.on('did-finish-load', () => {
// did-finish-load will trigger when most assets are done loading, probably // did-finish-load will trigger when most assets are done loading, probably

View File

@ -301,12 +301,8 @@ export default class FsDriverRN extends FsDriverBase {
return output ? output : null; return output ? output : null;
} }
public resolve(path: string) { public resolve(...paths: string[]): string {
throw new Error(`Not implemented: resolve(): ${path}`); throw new Error(`Not implemented: resolve(): ${JSON.stringify(paths)}`);
}
public resolveRelativePathWithinDir(_baseDir: string, relativePath: string) {
throw new Error(`Not implemented: resolveRelativePathWithinDir(): ${relativePath}`);
} }
public async md5File(path: string): Promise<string> { public async md5File(path: string): Promise<string> {

View File

@ -4,8 +4,8 @@ import { filename, fileExtension } from './path-utils';
const md5 = require('md5'); const md5 = require('md5');
export interface Stat { export interface Stat {
birthtime: number; birthtime: Date;
mtime: number; mtime: Date;
isDirectory(): boolean; isDirectory(): boolean;
path: string; path: string;
size: number; size: number;
@ -49,6 +49,10 @@ export default class FsDriverBase {
throw new Error('Not implemented'); 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> { public async readFileChunk(_handle: any, _length: number, _encoding = 'base64'): Promise<string> {
throw new Error('Not implemented'); throw new Error('Not implemented');
} }
@ -82,6 +86,26 @@ export default class FsDriverBase {
throw new Error('Not implemented'); 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[]> { protected async readDirStatsHandleRecursion_(basePath: string, stat: Stat, output: Stat[], options: ReadDirStatsOptions): Promise<Stat[]> {
if (options.recursive && stat.isDirectory()) { if (options.recursive && stat.isDirectory()) {
const subPath = `${basePath}/${stat.path}`; const subPath = `${basePath}/${stat.path}`;

View File

@ -31,8 +31,8 @@ export async function installDefaultPlugins(service: PluginService, defaultPlugi
const installedPlugins = Setting.value('installedDefaultPlugins'); const installedPlugins = Setting.value('installedDefaultPlugins');
for (let pluginId of defaultPluginsPaths) { for (const pluginStat of defaultPluginsPaths) {
pluginId = pluginId.path; 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 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; if (installedPlugins.includes(pluginId) || !defaultPluginsId.includes(pluginId)) continue;

View File

@ -38,7 +38,7 @@ describe('routes/notes', () => {
jest.spyOn(shim, 'fsDriver').mockImplementation(() => { jest.spyOn(shim, 'fsDriver').mockImplementation(() => {
return { return {
copy: fsDriverCopySpy, copy: fsDriverCopySpy,
}; } as any;
}); });
jest.spyOn(uuid, 'create').mockReturnValue('mocked_uuid_value'); jest.spyOn(uuid, 'create').mockReturnValue('mocked_uuid_value');

View File

@ -1,5 +1,6 @@
import * as React from 'react'; import * as React from 'react';
import { NoteEntity, ResourceEntity } from './services/database/types'; import { NoteEntity, ResourceEntity } from './services/database/types';
import type FsDriverBase from './fs-driver-base';
let isTestingEnv_ = false; let isTestingEnv_ = false;
@ -203,7 +204,7 @@ const shim = {
FormData: typeof FormData !== 'undefined' ? FormData : null, FormData: typeof FormData !== 'undefined' ? FormData : null,
fsDriver: (): any => { fsDriver: (): FsDriverBase => {
throw new Error('Not implemented'); throw new Error('Not implemented');
}, },