mirror of
https://github.com/MarSeventh/CloudFlare-ImgBed.git
synced 2026-05-03 02:16:35 +00:00
Feat:支持文件数据库索引,优化访问速度;后台增加系统状态页面
This commit is contained in:
@@ -1185,19 +1185,17 @@ async function promiseLimit(tasks, concurrency = BATCH_SIZE) {
|
||||
const promise = Promise.resolve().then(() => task()).then(result => {
|
||||
results[i] = result;
|
||||
return result;
|
||||
}).finally(() => {
|
||||
const index = executing.indexOf(promise);
|
||||
if (index >= 0) {
|
||||
executing.splice(index, 1);
|
||||
}
|
||||
});
|
||||
|
||||
executing.push(promise);
|
||||
|
||||
if (executing.length >= concurrency) {
|
||||
await Promise.race(executing);
|
||||
// 移除已完成的Promise
|
||||
for (let j = executing.length - 1; j >= 0; j--) {
|
||||
if (results[i] !== undefined || promise === executing[j]) {
|
||||
executing.splice(j, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user