fixed mem leak
This commit is contained in:
parent
e1da7c92d7
commit
f6d411e996
1 changed files with 3 additions and 4 deletions
7
main.ts
7
main.ts
|
@ -103,8 +103,6 @@ const options = {
|
||||||
async run() {
|
async run() {
|
||||||
const db = await createDatabase(args.values.db!);
|
const db = await createDatabase(args.values.db!);
|
||||||
const library = createLibrary(db);
|
const library = createLibrary(db);
|
||||||
const browser = await chromium.launch();
|
|
||||||
const platform = createPlatform({ db, browser });
|
|
||||||
const books: Array<Book> = [];
|
const books: Array<Book> = [];
|
||||||
|
|
||||||
if (args.values.download === "all") {
|
if (args.values.download === "all") {
|
||||||
|
@ -124,12 +122,13 @@ const options = {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const book of books) {
|
for (const book of books) {
|
||||||
|
const browser = await chromium.launch();
|
||||||
|
const platform = createPlatform({ db, browser });
|
||||||
const dir = `${args.values["out-dir"]!}/${book.id}`;
|
const dir = `${args.values["out-dir"]!}/${book.id}`;
|
||||||
await platform.download(dir, book);
|
await platform.download(dir, book);
|
||||||
await library.archive(dir, args.values["out-dir"]!, book);
|
await library.archive(dir, args.values["out-dir"]!, book);
|
||||||
|
await browser.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
await browser.close();
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
json: {
|
json: {
|
||||||
|
|
Loading…
Add table
Reference in a new issue