Skip to content

High performance self-hosted photo and video management solution.

fix(web): handle multiple downloads in safari (#21259)

Jason Rasmussen63088b22e070
diff --git a/web/src/lib/utils.ts b/web/src/lib/utils.ts
index 8ced866f6d..09205a2fc9 100644
--- a/web/src/lib/utils.ts
+++ b/web/src/lib/utils.ts
@@ -74,6 +74,10 @@ class ApiError extends Error {
}
}
+export const sleep = (ms: number) => {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+};
+
export const uploadRequest = async <T>(options: UploadRequestOptions): Promise<{ data: T; status: number }> => {
const { onUploadProgress: onProgress, data, url } = options;
diff --git a/web/src/lib/utils/asset-utils.ts b/web/src/lib/utils/asset-utils.ts
index 40eb9c9733..822820911e 100644
--- a/web/src/lib/utils/asset-utils.ts
+++ b/web/src/lib/utils/asset-utils.ts
@@ -9,7 +9,7 @@ import { assetsSnapshot } from '$lib/managers/timeline-manager/utils.svelte';
import type { AssetInteraction } from '$lib/stores/asset-interaction.svelte';
import { isSelectingAllAssets } from '$lib/stores/assets-store.svelte';
import { preferences } from '$lib/stores/user.store';
-import { downloadRequest, withError } from '$lib/utils';
+import { downloadRequest, sleep, withError } from '$lib/utils';
import { getByteUnitString } from '$lib/utils/byte-units';
import { getFormatter } from '$lib/utils/i18n';
import { navigate } from '$lib/utils/navigation';
@@ -278,7 +278,12 @@ export const downloadFile = async (asset: AssetResponseDto) => {
const queryParams = asQueryString(authManager.params);
- for (const { filename, id } of assets) {
+ for (const [i, { filename, id }] of assets.entries()) {
+ if (i !== 0) {
+ // play nice with Safari
+ await sleep(500);
+ }
+
try {
notificationController.show({
type: NotificationType.Info,