Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/profiles-modals/ImportProfileModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export default class ImportProfileModal extends mixins(ProfilesMixin) {
await ThunderstoreDownloaderProvider.instance.downloadImportedMods(comboList, ignoreCache, progressCallback);
await ProfileUtils.populateImportedProfile(comboList, mods, targetProfileName, isUpdate, zipPath, progressCallback);
} catch (e) {
await this.$store.dispatch('profiles/ensureProfileExists');
this.closeModal();
this.$store.commit('error/handleError', R2Error.fromThrownValue(e));
return;
Expand Down
12 changes: 12 additions & 0 deletions src/store/modules/ProfilesModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ export const ProfilesModule = {
}
},

async ensureProfileExists({commit, dispatch, rootGetters, state}) {
const activeProfile: Profile = rootGetters['profile/activeProfile'];

if (!(await FsProvider.instance.exists(activeProfile.getProfilePath()))) {
await dispatch('profile/updateActiveProfile', 'Default', { root: true });
commit(
'setProfileList',
state.profileList.filter((p) => p !== activeProfile.getProfileName())
);
}
},

async removeSelectedProfile({rootGetters, state, dispatch}) {
const activeProfile: Profile = rootGetters['profile/activeProfile'];
const path = activeProfile.getProfilePath();
Expand Down
9 changes: 7 additions & 2 deletions src/utils/ProfileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,13 @@ export async function populateImportedProfile(
await FileUtils.recursiveRemoveDirectoryIfExists(profile.getProfilePath());
}

await installModsToImportedProfile(comboList, exportModList, profile, progressCallback);
await extractConfigsToImportedProfile(zipPath, profile.getProfileName(), progressCallback);
try {
await installModsToImportedProfile(comboList, exportModList, profile, progressCallback);
await extractConfigsToImportedProfile(zipPath, profile.getProfileName(), progressCallback);
} catch (e) {
await FileUtils.recursiveRemoveDirectoryIfExists(profile.getProfilePath());
throw e;
}

if (isUpdate) {
progressCallback('Applying changes to updated profile...');
Expand Down
Loading