From 2f4fff2ff88709586986de01049ca450d930a223 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Sun, 20 Aug 2023 23:34:15 -0700 Subject: [PATCH] base: prevent infinite loop Signed-off-by: Varun Patil --- src/services/dav/base.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/services/dav/base.ts b/src/services/dav/base.ts index ad9e9493..aec20c44 100644 --- a/src/services/dav/base.ts +++ b/src/services/dav/base.ts @@ -154,6 +154,8 @@ async function getFilesInternal(fileIds: number[]): Promise { * @returns Generator of lists of results. Each list is of length n. */ export async function* runInParallel(promises: (() => Promise)[], n: number) { + if (!promises.length) return; + promises.reverse(); // reverse so we can use pop() efficiently const results: T[] = [];