mirror of
https://github.com/rommapp/romm.git
synced 2026-12-05 05:07:31 +01:00
Merge pull request #3382 from rommapp/copilot/fix-safari-webkit-upload-issues
Avoid Safari/WebKit stalls during chunked ROM uploads
This commit is contained in:
7
frontend/package-lock.json
generated
7
frontend/package-lock.json
generated
@@ -12,6 +12,7 @@
|
||||
"@mdi/font": "7.4.47",
|
||||
"@vueuse/core": "^13.7.0",
|
||||
"axios": "^1.16.0",
|
||||
"bowser": "^2.14.1",
|
||||
"cronstrue": "^2.57.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"js-cookie": "^3.0.5",
|
||||
@@ -4772,6 +4773,12 @@
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/bowser": {
|
||||
"version": "2.14.1",
|
||||
"resolved": "https://registry.npmjs.org/bowser/-/bowser-2.14.1.tgz",
|
||||
"integrity": "sha512-tzPjzCxygAKWFOJP011oxFHs57HzIhOEracIgAePE4pqB3LikALKnSzUyU4MGs9/iCEUuHlAJTjTc5M+u7YEGg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "5.0.5",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.5.tgz",
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
"@mdi/font": "7.4.47",
|
||||
"@vueuse/core": "^13.7.0",
|
||||
"axios": "^1.16.0",
|
||||
"bowser": "^2.14.1",
|
||||
"cronstrue": "^2.57.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"js-cookie": "^3.0.5",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { AxiosProgressEvent } from "axios";
|
||||
import Bowser from "bowser";
|
||||
import type {
|
||||
Body_delete_roms_api_roms_delete_post as DeleteRomsInput,
|
||||
Body_update_rom_api_roms__id__put as UpdateRomInput,
|
||||
@@ -28,6 +29,10 @@ const DOWNLOAD_CLEANUP_DELAY = 100;
|
||||
const UPLOAD_CHUNK_SIZE = 10 * 1024 * 1024; // 10MB per chunk
|
||||
const MAX_CHUNK_RETRIES = 3;
|
||||
|
||||
const browser = Bowser.getParser(window.navigator.userAgent);
|
||||
const engineName = browser.getEngineName();
|
||||
const trackChunkUploadProgress = engineName !== "WebKit";
|
||||
|
||||
async function uploadRomChunked({
|
||||
platformId,
|
||||
file,
|
||||
@@ -64,17 +69,26 @@ async function uploadRomChunked({
|
||||
"X-Chunk-Index": i.toString(),
|
||||
},
|
||||
timeout: 120000,
|
||||
onUploadProgress: (progressEvent: AxiosProgressEvent) => {
|
||||
const chunkFraction = progressEvent.progress ?? 0;
|
||||
const overall = ((i + chunkFraction) / totalChunks) * 100;
|
||||
uploadStore.updateChunkProgress(
|
||||
file.name,
|
||||
overall,
|
||||
file.size,
|
||||
progressEvent.rate,
|
||||
);
|
||||
},
|
||||
...(trackChunkUploadProgress && {
|
||||
onUploadProgress: (progressEvent: AxiosProgressEvent) => {
|
||||
const chunkFraction = progressEvent.progress ?? 0;
|
||||
const overall = ((i + chunkFraction) / totalChunks) * 100;
|
||||
uploadStore.updateChunkProgress(
|
||||
file.name,
|
||||
overall,
|
||||
file.size,
|
||||
progressEvent.rate,
|
||||
);
|
||||
},
|
||||
}),
|
||||
});
|
||||
if (!trackChunkUploadProgress) {
|
||||
uploadStore.updateChunkProgress(
|
||||
file.name,
|
||||
((i + 1) / totalChunks) * 100,
|
||||
file.size,
|
||||
);
|
||||
}
|
||||
lastError = null;
|
||||
break;
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user