mirror of
https://github.com/immich-app/immich.git
synced 2025-06-01 04:36:19 -04:00
fix(web): mismatched deviceAssetId when uploading images (#15130)
Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
parent
77d4eb8787
commit
abf5b0afe1
@ -83,14 +83,19 @@ export const openFileUploadDialog = async (options: FileUploadParam = {}) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fileUploadHandler = async (files: File[], albumId?: string, assetId?: string): Promise<string[]> => {
|
export const fileUploadHandler = async (
|
||||||
|
files: File[],
|
||||||
|
albumId?: string,
|
||||||
|
replaceAssetId?: string,
|
||||||
|
): Promise<string[]> => {
|
||||||
const extensions = await getExtensions();
|
const extensions = await getExtensions();
|
||||||
const promises = [];
|
const promises = [];
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const name = file.name.toLowerCase();
|
const name = file.name.toLowerCase();
|
||||||
if (extensions.some((extension) => name.endsWith(extension))) {
|
if (extensions.some((extension) => name.endsWith(extension))) {
|
||||||
uploadAssetsStore.addItem({ id: getDeviceAssetId(file), file, albumId });
|
const deviceAssetId = getDeviceAssetId(file);
|
||||||
promises.push(uploadExecutionQueue.addTask(() => fileUploader(file, albumId, assetId)));
|
uploadAssetsStore.addItem({ id: deviceAssetId, file, albumId });
|
||||||
|
promises.push(uploadExecutionQueue.addTask(() => fileUploader(file, deviceAssetId, albumId, replaceAssetId)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,9 +108,13 @@ function getDeviceAssetId(asset: File) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: should probably use the @api SDK
|
// TODO: should probably use the @api SDK
|
||||||
async function fileUploader(assetFile: File, albumId?: string, replaceAssetId?: string): Promise<string | undefined> {
|
async function fileUploader(
|
||||||
|
assetFile: File,
|
||||||
|
deviceAssetId: string,
|
||||||
|
albumId?: string,
|
||||||
|
replaceAssetId?: string,
|
||||||
|
): Promise<string | undefined> {
|
||||||
const fileCreatedAt = new Date(assetFile.lastModified).toISOString();
|
const fileCreatedAt = new Date(assetFile.lastModified).toISOString();
|
||||||
const deviceAssetId = getDeviceAssetId(assetFile);
|
|
||||||
const $t = get(t);
|
const $t = get(t);
|
||||||
|
|
||||||
uploadAssetsStore.markStarted(deviceAssetId);
|
uploadAssetsStore.markStarted(deviceAssetId);
|
||||||
@ -148,6 +157,7 @@ async function fileUploader(assetFile: File, albumId?: string, replaceAssetId?:
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error calculating sha1 file=${assetFile.name})`, error);
|
console.error(`Error calculating sha1 file=${assetFile.name})`, error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user