From 4703eec045c61cbabe199ef7e30dad94bd3e43da Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Fri, 4 Apr 2025 19:20:02 +0800 Subject: [PATCH] fix: set correct filename in openFile API, closes #803 (#810) --- apps/readest-app/src/services/nativeAppService.ts | 2 +- apps/readest-app/src/services/webAppService.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/readest-app/src/services/nativeAppService.ts b/apps/readest-app/src/services/nativeAppService.ts index 448785c9..1f3e0994 100644 --- a/apps/readest-app/src/services/nativeAppService.ts +++ b/apps/readest-app/src/services/nativeAppService.ts @@ -89,7 +89,7 @@ export const nativeFileSystem: FileSystem = { // Once the bug is resolved, we should switch back to using NativeFile. // RemoteFile is not usable on Android due to unknown issues of range fetch with Android WebView. const absolutePath = await join(prefix, path); - return await new RemoteFile(this.getURL(absolutePath), path).open(); + return await new RemoteFile(this.getURL(absolutePath), fname).open(); } else { return await new NativeFile(fp, fname, base ? baseDir : null).open(); } diff --git a/apps/readest-app/src/services/webAppService.ts b/apps/readest-app/src/services/webAppService.ts index a65249a2..8cde13da 100644 --- a/apps/readest-app/src/services/webAppService.ts +++ b/apps/readest-app/src/services/webAppService.ts @@ -54,12 +54,12 @@ const indexedDBFileSystem: FileSystem = { return path; } }, - async openFile(path: string, base: BaseDir) { + async openFile(path: string, base: BaseDir, filename?: string) { if (isValidURL(path)) { - return await new RemoteFile(path).open(); + return await new RemoteFile(path, filename).open(); } else { const content = await this.readFile(path, base, 'binary'); - return new File([content], path); + return new File([content], filename || path); } }, async copyFile(srcPath: string, dstPath: string, base: BaseDir) {