mirror of
https://github.com/immich-app/immich.git
synced 2025-07-01 21:40:10 +02:00
feat: user preferences for archive download size (#10296)
* feat: user preferences for archive download size * chore: open api * chore: clean up --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
parent
596412cb8f
commit
dddc06c3b2
19 changed files with 442 additions and 24 deletions
web/src/lib/utils
|
@ -5,7 +5,8 @@ import type { AssetInteractionStore } from '$lib/stores/asset-interaction.store'
|
|||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||
import { BucketPosition, isSelectingAllAssets, type AssetStore } from '$lib/stores/assets.store';
|
||||
import { downloadManager } from '$lib/stores/download';
|
||||
import { downloadRequest, getKey, s } from '$lib/utils';
|
||||
import { preferences } from '$lib/stores/user.store';
|
||||
import { downloadRequest, getKey, s, withError } from '$lib/utils';
|
||||
import { createAlbum } from '$lib/utils/album-utils';
|
||||
import { asByteUnitString } from '$lib/utils/byte-units';
|
||||
import { encodeHTMLSpecialChars } from '$lib/utils/string-utils';
|
||||
|
@ -20,7 +21,6 @@ import {
|
|||
type AssetResponseDto,
|
||||
type AssetTypeEnum,
|
||||
type DownloadInfoDto,
|
||||
type DownloadResponseDto,
|
||||
type UserResponseDto,
|
||||
} from '@immich/sdk';
|
||||
import { DateTime } from 'luxon';
|
||||
|
@ -94,18 +94,19 @@ export const downloadBlob = (data: Blob, filename: string) => {
|
|||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
export const downloadArchive = async (fileName: string, options: DownloadInfoDto) => {
|
||||
let downloadInfo: DownloadResponseDto | null = null;
|
||||
export const downloadArchive = async (fileName: string, options: Omit<DownloadInfoDto, 'archiveSize'>) => {
|
||||
const $preferences = get(preferences);
|
||||
const dto = { ...options, archiveSize: $preferences.download.archiveSize };
|
||||
|
||||
try {
|
||||
downloadInfo = await getDownloadInfo({ downloadInfoDto: options, key: getKey() });
|
||||
} catch (error) {
|
||||
const [error, downloadInfo] = await withError(() => getDownloadInfo({ downloadInfoDto: dto, key: getKey() }));
|
||||
if (error) {
|
||||
handleError(error, 'Unable to download files');
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: prompt for big download
|
||||
// const total = downloadInfo.totalSize;
|
||||
if (!downloadInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let index = 0; index < downloadInfo.archives.length; index++) {
|
||||
const archive = downloadInfo.archives[index];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue