generated from ztimson/template
Fixed delete by href
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/zim-utils",
|
"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",
|
"description": "Native, dependency-light ZIM archive reader/searcher and Kiwix catalog downloader for Node.js",
|
||||||
"author": "Zak Timson",
|
"author": "Zak Timson",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -79,9 +79,10 @@ export class ZimManager {
|
|||||||
|
|
||||||
async delete(nameOrFile) {
|
async delete(nameOrFile) {
|
||||||
const local = await this.list();
|
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}`);
|
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();
|
const server = await this.#ensureServer();
|
||||||
await server.reload();
|
await server.reload();
|
||||||
return {file: match.file, status: 'deleted'};
|
return {file: match.file, status: 'deleted'};
|
||||||
|
|||||||
Reference in New Issue
Block a user