Hotfix downloading multi-files

This commit is contained in:
Georges-Antoine Assi
2023-08-14 18:12:31 -04:00
parent 282d147719
commit fb49f653f8
2 changed files with 17 additions and 7 deletions

View File

@@ -21,14 +21,16 @@ export async function fetchRomApi(platform, rom) {
return axios.get(`/api/platforms/${platform}/roms/${rom}`);
}
// Listen for multi-file download completion events
socket.on("download:complete", ({ id }) => {
function clearRomFromDownloads({ id }) {
const downloadStore = useDownloadStore();
useDownloadStore().remove(id);
downloadStore.remove(id);
// Disconnect socket when no more downloads are in progress
if (downloadStore.value.length === 0) socket.disconnect();
});
}
// Listen for multi-file download completion events
socket.on("download:complete", clearRomFromDownloads);
// Used only for multi-file downloads
export async function downloadRomApi(rom, files) {
@@ -46,6 +48,11 @@ export async function downloadRomApi(rom, files) {
if (!socket.connected) socket.connect();
useDownloadStore().add(rom.id);
// Clear download state after 60 seconds in case error/timeout
setTimeout(() => {
clearRomFromDownloads(rom);
}, 60 * 1000);
}
export async function updateRomApi(rom, updatedData, renameAsIGDB) {

View File

@@ -41,12 +41,15 @@ export default defineConfig(({ mode }) => {
],
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
navigateFallbackDenylist: [/^\/assets\/romm\/library/],
globPatterns: ["**/*.{js,css,html,ico,png,svg}"],
navigateFallbackDenylist: [
/\/assets\/romm\/library/,
/\/api\/platforms\/.*\/roms\/.*\/download/,
],
},
devOptions: {
enabled: false,
type: 'module',
type: "module",
},
}),
],