Skip to content

Commit

Permalink
Fix getModList errors being silently ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
VilppeRiskidev committed Feb 5, 2025
1 parent d03f65a commit c868b98
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 32 deletions.
33 changes: 25 additions & 8 deletions src/components/views/DownloadModModal.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
<template>
<div>
<div id='downloadProgressModal' :class="['modal', {'is-active':$store.state.download.isModProgressModalOpen}]" v-if="$store.getters['download/currentDownload'] !== null">
<div
id='downloadProgressModal'
:class="['modal', {'is-active':$store.state.download.isModProgressModalOpen}]"
v-if="$store.getters['download/currentDownload'] !== null"
>
<div class="modal-background" @click="setIsModProgressModalOpen(false);"></div>
<div class='modal-content'>
<div class='notification is-info'>
<h3 class='title'>Downloading and installing {{$store.getters['download/currentDownload'].modName}}</h3>

<h3 v-if="$store.getters['download/currentDownload'].downloadProgress < 100" class='title'>
Downloading {{$store.getters['download/currentDownload'].modName}}
</h3>
<h3 v-else class='title'>
Installing {{$store.getters['download/currentDownload'].modName}}
</h3>

<p>Downloading: {{Math.floor($store.getters['download/currentDownload'].downloadProgress)}}% complete</p>

<Progress
:max='100'
:value="$store.getters['download/currentDownload'].downloadProgress"
:className="['is-dark']"
/>
<p v-if="$store.getters['download/currentDownload'].installProgress">Installing: {{$store.getters['download/currentDownload'].installProgress}}% complete</p>

<p v-if="$store.getters['download/currentDownload'].installProgress">
Installing: {{Math.floor($store.getters['download/currentDownload'].installProgress)}}% complete
</p>
<p v-else>Installing: waiting for download to finish</p>

<Progress
:max='100'
:value="$store.getters['download/currentDownload'].installProgress"
Expand Down Expand Up @@ -101,11 +117,12 @@ import ProfileModList from '../../r2mm/mods/ProfileModList';
}
}
const modList = await ProfileModList.getModList(profile.asImmutableProfile());
if (!(modList instanceof R2Error)) {
const err = await ConflictManagementProvider.instance.resolveConflicts(modList, profile.asImmutableProfile());
if (err instanceof R2Error) {
return reject(err);
}
if (modList instanceof R2Error) {
return reject(modList);
}
const err = await ConflictManagementProvider.instance.resolveConflicts(modList, profile.asImmutableProfile());
if (err instanceof R2Error) {
return reject(err);
}
return resolve();
});
Expand Down
46 changes: 27 additions & 19 deletions src/pages/DownloadMonitor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@
<Progress
:max='100'
:value='100'
:className="['is-danger']"
:className="['is-success']"
/>
</div>

<div v-else-if="downloadObject.downloadProgress === 100 && downloadObject.installProgress === 100">
<p>Download complete</p>
<Progress
:max='100'
:value='100'
:className="['is-success']"
/>
</div>

Expand All @@ -42,24 +51,23 @@
/>
</div>

<div v-if="downloadObject.installProgress < 100" class="col">
<div v-if="downloadObject.downloadProgress < 100">
<p>Installing:</p>
<p v-if="downloadObject.downloadProgress < 100">Waiting for download to finish</p>
<Progress
:max='100'
:className="['is-info']"
/>
</div>
<div v-else>
<p>Installing: {{ downloadObject.modName }}</p>
<p>{{Math.min(Math.floor(downloadObject.installProgress), 100)}}% complete</p>
<Progress
:max='100'
:value='downloadObject.installProgress'
:className="['is-info']"
/>
</div>
<div v-if="downloadObject.downloadProgress < 100" class="col">
<p>Installing:</p>
<p>Waiting for download to finish</p>
<Progress
:max='100'
:value='0'
:className="['is-info']"
/>
</div>
<div v-else class="col">
<p>Installing: {{ downloadObject.modName }}</p>
<p>{{Math.min(Math.floor(downloadObject.installProgress), 100)}}% complete</p>
<Progress
:max='100'
:value='downloadObject.installProgress'
:className="['is-info']"
/>
</div>

</div>
Expand Down
4 changes: 2 additions & 2 deletions src/r2mm/downloading/BetterThunderstoreDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class BetterThunderstoreDownloader extends ThunderstoreDownloader
console.error(`Ignore unknown status code "${status}"`);
return;
}
totalProgressCallback(Math.round(totalDownloadProgress), modInProgressName, status, err);
totalProgressCallback(totalDownloadProgress, modInProgressName, status, err);
}

for (const comboInProgress of allModsToDownload) {
Expand Down Expand Up @@ -196,7 +196,7 @@ export default class BetterThunderstoreDownloader extends ThunderstoreDownloader

public generateProgressPercentage(progress: number, currentIndex: number, total: number): number {
const completedProgress = (currentIndex / total) * 100;
return completedProgress + (progress * 1/total);
return Math.round(completedProgress + (progress * 1/total));
}

public async queueDownloadDependencies(entries: IterableIterator<[number, ThunderstoreCombo]>, ignoreCache: boolean, callback: (progress: number, modName: string, status: number, err: R2Error | null) => void) {
Expand Down
5 changes: 2 additions & 3 deletions src/utils/ProfileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,11 @@ export async function installModsToProfile(

const installedVersions = profileMods.map((m) => m.getDependencyString());
const disabledMods = disabledModsOverride || profileMods.filter((m) => !m.isEnabled()).map((m) => m.getName());
let currentMod;
let modName = 'Unknown';

try {
for (const [index, comboMod] of comboList.entries()) {
currentMod = comboMod;
modName = currentMod.getMod().getFullName();
modName = comboMod.getMod().getFullName();

const manifestMod = new ManifestV2().fromThunderstoreMod(comboMod.getMod(), comboMod.getVersion());

Expand Down

0 comments on commit c868b98

Please sign in to comment.