fix(cbz): fix issue where CBZ files fail to reopen after being closed, closes #2183 (#2190)

This commit is contained in:
Huang Xin
2025-10-10 11:50:40 +08:00
committed by GitHub
parent ad81376da8
commit 42c8702704
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -270,13 +270,13 @@ export abstract class BaseAppService implements AppService {
fileobj = file;
filename = file.name;
}
if (filename.endsWith('.txt')) {
if (/\.txt$/i.test(filename)) {
const txt2epub = new TxtToEpubConverter();
({ file: fileobj } = await txt2epub.convert({ file: fileobj }));
}
({ book: loadedBook, format } = await new DocumentLoader(fileobj).open());
const metadataTitle = formatTitle(loadedBook.metadata.title);
if (!metadataTitle || !metadataTitle.trim()) {
if (!metadataTitle || !metadataTitle.trim() || metadataTitle === filename) {
loadedBook.metadata.title = getBaseFilename(filename);
}
} catch (error) {
@@ -326,7 +326,7 @@ export abstract class BaseAppService implements AppService {
!transient &&
(!(await this.fs.exists(getLocalBookFilename(book), 'Books')) || overwrite)
) {
if (filename.endsWith('.txt')) {
if (/\.txt$/i.test(filename)) {
await this.fs.writeFile(getLocalBookFilename(book), 'Books', fileobj);
} else if (typeof file === 'string' && isContentURI(file)) {
await this.fs.copyFile(file, getLocalBookFilename(book), 'Books');
@@ -308,7 +308,7 @@ export const nativeFileSystem: FileSystem = {
}
}
};
await readDirRecursively(path, '', entries, fileList);
await readDirRecursively(fp, '', entries, fileList);
return fileList;
},
async exists(path: string, base: BaseDir) {