Skip to content

Commit

Permalink
fix: 修复下载结束不会自动退出的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Dec 3, 2023
1 parent 72fe208 commit 1acc9ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/lib/worker_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ export class WorkerPool<T = unknown, R = unknown> extends EventEmitter {
get freeNum() {
return this.freeWorkers.length;
}
constructor(
private processorFile: string,
public numThreads = 0
) {
constructor(private processorFile: string, public numThreads = 0) {

Check warning on line 38 in src/lib/worker_pool.ts

View workflow job for this annotation

GitHub Actions / Node 16 on ubuntu-latest

Replace `private·processorFile:·string,·public·numThreads·=·0` with `⏎····private·processorFile:·string,⏎····public·numThreads·=·0⏎··`

Check warning on line 38 in src/lib/worker_pool.ts

View workflow job for this annotation

GitHub Actions / Node 16 on macos-latest

Replace `private·processorFile:·string,·public·numThreads·=·0` with `⏎····private·processorFile:·string,⏎····public·numThreads·=·0⏎··`

Check warning on line 38 in src/lib/worker_pool.ts

View workflow job for this annotation

GitHub Actions / Node 18 on ubuntu-latest

Replace `private·processorFile:·string,·public·numThreads·=·0` with `⏎····private·processorFile:·string,⏎····public·numThreads·=·0⏎··`
super();

numThreads = +numThreads || cpus().length;
Expand Down
4 changes: 4 additions & 0 deletions src/m3u8-batch-download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { logger } from './lib/utils';
async function formatUrls(urls: string[], options: M3u8DLOptions): Promise<Map<string, M3u8DLOptions>> {
const taskset = new Map<string, M3u8DLOptions>();
for (const url of urls) {
if (!url) continue;
if (existsSync(url)) {
const content = await promises.readFile(url, 'utf8');
if (content.includes('.m3u8')) {
Expand Down Expand Up @@ -67,5 +68,8 @@ export async function m3u8BatchDownload(urls: string[], options: M3u8DLOptions)
};

run();
}).then(d => {
if (workPoll.freeNum === workPoll.numThreads) workPoll.close();
return d;
});
}

0 comments on commit 1acc9ea

Please sign in to comment.