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 (#15130)
Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
parent
77d4eb8787
commit
abf5b0afe1
1 changed files with 15 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue