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 19, 2025
1 parent d03f65a commit a362322
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 31 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
44 changes: 26 additions & 18 deletions src/pages/DownloadMonitor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
/>
</div>

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

<div v-else class="row">

<div class="col">
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
5 changes: 3 additions & 2 deletions src/r2mm/downloading/BetterThunderstoreDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,19 @@ export default class BetterThunderstoreDownloader extends ThunderstoreDownloader
}

const dependencies = await this.getDependenciesWithCorrectVersions(combo, modList);
const allModsToDownload = [...dependencies, combo];
const allModsToDownload = [combo, ...dependencies];

let modInProgressName = combo.getMod().getName();
let downloadCount = 0;
// Mark the mod 80% processed when the download completes, save the remaining 20% for extracting.
const singleModProgressCallback = (downloadProgress: number, status: number, err: R2Error | null) => {
if (status === StatusEnum.FAILURE) {
throw err;
}

let totalDownloadProgress: number;
if (status === StatusEnum.PENDING) {
totalDownloadProgress = this.generateProgressPercentage(downloadProgress, downloadCount, allModsToDownload.length);
totalDownloadProgress = this.generateProgressPercentage(downloadProgress * 0.8, downloadCount, allModsToDownload.length);
} else if (status === StatusEnum.SUCCESS) {
totalDownloadProgress = this.generateProgressPercentage(100, downloadCount, allModsToDownload.length);
downloadCount += 1;
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().getName();

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

Expand Down

0 comments on commit a362322

Please sign in to comment.