Skip to content

Commit

Permalink
Merge pull request #16502 from Nexus-Mods/16363-bugfix-importing-with…
Browse files Browse the repository at this point in the history
…-no-active-gamemode

fixed attempts to import local downloads when no game is active
  • Loading branch information
insomnious authored Oct 7, 2024
2 parents 3316ef7 + c3d29ae commit 0d2d84e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/extensions/download_management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,9 @@ function postImport(api: IExtensionApi, destination: string,
fileSize: number, silent: boolean): Promise<string> {
const store = api.store;
const gameMode = selectors.activeGameId(store.getState());
if (gameMode === undefined) {
return Promise.reject(new Error('no active game'));
}

const dlId = shortid();
const fileName = path.basename(destination);
Expand Down Expand Up @@ -477,6 +480,7 @@ function move(api: IExtensionApi,
.then(() => fs.copyAsync(source, destination))
.then(() => postImport(api, destination, fileSize, silent))
.catch(err => {
api.showErrorNotification('Import Failed', err, { allowReport: false });
log('info', 'failed to copy', {error: err.message});
return undefined;
})
Expand Down Expand Up @@ -507,6 +511,7 @@ function importDirectory(api: IExtensionApi,
.then(() => fs.statAsync(destination))
.then((stat: fs.Stats) => postImport(api, destination, stat.size, silent))
.catch(err => {
api.showErrorNotification('Import Failed', err, { allowReport: false });
log('info', 'failed to copy', {error: err.message});
return undefined;
})
Expand Down

0 comments on commit 0d2d84e

Please sign in to comment.