diff --git a/library.ts b/library.ts index 49e66eb..c556d28 100644 --- a/library.ts +++ b/library.ts @@ -107,6 +107,10 @@ on conflict(reader_url) book.title }`.replace(/[/]/g, "%2F"); + await fs.mkdir(opts.outDir, { + recursive: true, + }); + const files = await fs.readdir(path); if (files.every((f) => f.match(/[.](zip|cbz)$/))) { @@ -117,14 +121,15 @@ on conflict(reader_url) } for (const [n, f] of Object.entries(files)) { - await fs.rename( + await fs.copyFile( `${path}/${f}`, `${opts.outDir}/${title}${ files.length > 1 ? ` - ${pad(n)}` : "" }.${f.split(".").at(-1)}`, ); } - await fs.rmdir(path); + + await fs.rm(path, { recursive: true }); return; } diff --git a/package-lock.json b/package-lock.json index 29201c7..e3ea5ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@fogtype/gadl", - "version": "1.4.1", + "version": "1.4.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@fogtype/gadl", - "version": "1.4.1", + "version": "1.4.2", "license": "AGPL-3.0", "dependencies": { "fflate": "^0.8.1",