mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:06:56 -04:00
- fix concurrency being pseudo concurrency
This commit is contained in:
parent
3ab7438036
commit
32dfc3ddcb
@ -100,11 +100,9 @@ export const checkForDuplicates = async (files: string[], { concurrency, skipHas
|
|||||||
const newFiles: string[] = [];
|
const newFiles: string[] = [];
|
||||||
const duplicates: Asset[] = [];
|
const duplicates: Asset[] = [];
|
||||||
|
|
||||||
const queue = new Queue<string[], AssetBulkUploadCheckResults>(
|
const queue = new Queue<string, AssetBulkUploadCheckResults>(
|
||||||
async (filepaths: string[]) => {
|
async (filepath: string) => {
|
||||||
const dto = await Promise.all(
|
const dto = [{ id: filepath, checksum: await sha1(filepath) }];
|
||||||
filepaths.map(async (filepath) => ({ id: filepath, checksum: await sha1(filepath) })),
|
|
||||||
);
|
|
||||||
const response = await checkBulkUpload({ assetBulkUploadCheckDto: { assets: dto } });
|
const response = await checkBulkUpload({ assetBulkUploadCheckDto: { assets: dto } });
|
||||||
const results = response.results as AssetBulkUploadCheckResults;
|
const results = response.results as AssetBulkUploadCheckResults;
|
||||||
for (const { id: filepath, assetId, action } of results) {
|
for (const { id: filepath, assetId, action } of results) {
|
||||||
@ -115,15 +113,17 @@ export const checkForDuplicates = async (files: string[], { concurrency, skipHas
|
|||||||
duplicates.push({ id: assetId as string, filepath });
|
duplicates.push({ id: assetId as string, filepath });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
progressBar.increment(filepaths.length);
|
progressBar.increment();
|
||||||
return results;
|
return results;
|
||||||
},
|
},
|
||||||
{ concurrency, retry: 3 },
|
{ concurrency, retry: 3 },
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const items of chunk(files, concurrency)) {
|
await Promise.all(
|
||||||
await queue.push(items);
|
files.map(async (item) => {
|
||||||
}
|
await queue.push(item);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
await queue.drained();
|
await queue.drained();
|
||||||
|
|
||||||
@ -201,9 +201,11 @@ export const uploadFiles = async (files: string[], { dryRun, concurrency }: Uplo
|
|||||||
{ concurrency, retry: 3 },
|
{ concurrency, retry: 3 },
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const filepath of files) {
|
await Promise.all(
|
||||||
await queue.push(filepath);
|
files.map(async (item) => {
|
||||||
}
|
await queue.push(item);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
await queue.drained();
|
await queue.drained();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user