1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-23 20:22:45 +01:00

fix(web): mismatched deviceAssetId when uploading images ()

Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
Jin Xuan 2025-01-12 12:28:39 +08:00 committed by GitHub
parent 77d4eb8787
commit abf5b0afe1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 promises = [];
for (const file of files) {
const name = file.name.toLowerCase();
if (extensions.some((extension) => name.endsWith(extension))) {
uploadAssetsStore.addItem({ id: getDeviceAssetId(file), file, albumId });
promises.push(uploadExecutionQueue.addTask(() => fileUploader(file, albumId, assetId)));
const deviceAssetId = getDeviceAssetId(file);
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
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 deviceAssetId = getDeviceAssetId(assetFile);
const $t = get(t);
uploadAssetsStore.markStarted(deviceAssetId);
@ -148,6 +157,7 @@ async function fileUploader(assetFile: File, albumId?: string, replaceAssetId?:
}
} catch (error) {
console.error(`Error calculating sha1 file=${assetFile.name})`, error);
throw error;
}
}