1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-01 16:41:59 +00:00

fix(web): download livephotos video part correctly (#3230)

This commit is contained in:
Alex 2023-07-13 09:00:46 -05:00 committed by GitHub
parent b71d7e33bb
commit 863e983726
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -88,14 +88,17 @@ export const downloadArchive = async (
};
export const downloadFile = async (asset: AssetResponseDto, key?: string) => {
const filenames = [`${asset.originalFileName}.${getFilenameExtension(asset.originalPath)}`];
const assets = [{ filename: `${asset.originalFileName}.${getFilenameExtension(asset.originalPath)}`, id: asset.id }];
if (asset.livePhotoVideoId) {
filenames.push(`${asset.originalFileName}.mov`);
assets.push({
filename: `${asset.originalFileName}.mov`,
id: asset.livePhotoVideoId,
});
}
for (const filename of filenames) {
for (const asset of assets) {
try {
updateDownload(filename, 0);
updateDownload(asset.filename, 0);
const { data } = await api.assetApi.downloadFile(
{ id: asset.id, key },
@ -103,17 +106,17 @@ export const downloadFile = async (asset: AssetResponseDto, key?: string) => {
responseType: 'blob',
onDownloadProgress: (event: ProgressEvent) => {
if (event.lengthComputable) {
updateDownload(filename, Math.floor((event.loaded / event.total) * 100));
updateDownload(asset.filename, Math.floor((event.loaded / event.total) * 100));
}
},
},
);
downloadBlob(data, filename);
downloadBlob(data, asset.filename);
} catch (e) {
handleError(e, `Error downloading ${filename}`);
handleError(e, `Error downloading ${asset.filename}`);
} finally {
setTimeout(() => clearDownload(filename), 3_000);
setTimeout(() => clearDownload(asset.filename), 3_000);
}
}
};