Fixed delete by href
All checks were successful
Publish Library / Build NPM Project (push) Successful in 44s
Publish Library / Tag Version (push) Successful in 26s

This commit is contained in:
2026-08-25 01:00:28 -04:00
parent 7a2f17bfe9
commit 57cb9c8bd1
2 changed files with 4 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@ztimson/zim-utils",
"version": "0.3.3",
"version": "0.3.4",
"description": "Native, dependency-light ZIM archive reader/searcher and Kiwix catalog downloader for Node.js",
"author": "Zak Timson",
"license": "MIT",

View File

@@ -79,9 +79,10 @@ export class ZimManager {
async delete(nameOrFile) {
const local = await this.list();
const match = local.find(l => l.name === nameOrFile || l.file === nameOrFile);
const match = local.find(l => l.name === nameOrFile || l.href === nameOrFile);
if (!match) throw new Error(`ZIM not found locally: ${nameOrFile}`);
await fs.promises.rm(path.join(this.#dir, match.file), {force: true});
const file = match.href + (match.href.endsWith('.zim') ? '' : '.zim');
await fs.promises.rm(path.join(this.#dir, file), {force: true});
const server = await this.#ensureServer();
await server.reload();
return {file: match.file, status: 'deleted'};