generated from ztimson/template
Garbage colleciton fix
This commit is contained in:
@@ -169,8 +169,12 @@ export class ZimManager {
|
||||
pending = new ZimReader(file, {clusterTTL: this.#clusterTTL}).open();
|
||||
this.#opening.set(file, pending);
|
||||
}
|
||||
const reader = await pending;
|
||||
this.#opening.delete(file);
|
||||
let reader;
|
||||
try {
|
||||
reader = await pending;
|
||||
} finally {
|
||||
this.#opening.delete(file);
|
||||
}
|
||||
entry = this.#readers.get(file) ?? {reader};
|
||||
this.#readers.set(file, entry);
|
||||
}
|
||||
|
||||
@@ -294,8 +294,14 @@ export class ZimReader {
|
||||
/** Opens the archive and parses its header + mimetype list. */
|
||||
async open() {
|
||||
this.#fd = await fs.promises.open(this.path, 'r');
|
||||
await this.#readHeader();
|
||||
await this.#readMimeTypes();
|
||||
try {
|
||||
await this.#readHeader();
|
||||
await this.#readMimeTypes();
|
||||
} catch (e) {
|
||||
await this.#fd.close();
|
||||
this.#fd = null;
|
||||
throw e;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user