generated from ztimson/template
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 96ddcbe67a |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/zim-utils",
|
"name": "@ztimson/zim-utils",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"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",
|
||||||
|
|||||||
@@ -169,8 +169,12 @@ export class ZimManager {
|
|||||||
pending = new ZimReader(file, {clusterTTL: this.#clusterTTL}).open();
|
pending = new ZimReader(file, {clusterTTL: this.#clusterTTL}).open();
|
||||||
this.#opening.set(file, pending);
|
this.#opening.set(file, pending);
|
||||||
}
|
}
|
||||||
const reader = await pending;
|
let reader;
|
||||||
this.#opening.delete(file);
|
try {
|
||||||
|
reader = await pending;
|
||||||
|
} finally {
|
||||||
|
this.#opening.delete(file);
|
||||||
|
}
|
||||||
entry = this.#readers.get(file) ?? {reader};
|
entry = this.#readers.get(file) ?? {reader};
|
||||||
this.#readers.set(file, entry);
|
this.#readers.set(file, entry);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,8 +294,14 @@ export class ZimReader {
|
|||||||
/** Opens the archive and parses its header + mimetype list. */
|
/** Opens the archive and parses its header + mimetype list. */
|
||||||
async open() {
|
async open() {
|
||||||
this.#fd = await fs.promises.open(this.path, 'r');
|
this.#fd = await fs.promises.open(this.path, 'r');
|
||||||
await this.#readHeader();
|
try {
|
||||||
await this.#readMimeTypes();
|
await this.#readHeader();
|
||||||
|
await this.#readMimeTypes();
|
||||||
|
} catch (e) {
|
||||||
|
await this.#fd.close();
|
||||||
|
this.#fd = null;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user