Skip to content

Commit

Permalink
Merge pull request ebkr#1424 from ebkr/filtering-ordering-race-condition
Browse files Browse the repository at this point in the history
Attempt to mitigate a race condition corrupting the mods.yml file
  • Loading branch information
anttimaki committed Sep 11, 2024
2 parents 1ffee55 + 0cdef1c commit 69cda7c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/store/modules/ProfileModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,23 @@ export default {
},

async saveModListToDisk(
{dispatch},
{dispatch, getters},
params: {
mods: ManifestV2[],
profile: Profile,
}
) {
const {mods, profile} = params;

// Sanity check against race conditions. E.g. using the text filter
// disables ordering, but if the user is fast enough they can start
// dragging a mod after writing into input. If the dragging is then
// finished succesfully after the filter is applied, mods.yml would
// be overwritten to contain only the visible, filtered mods.
if (!getters['canSortMods']) {
return;
}

ProfileModList.requestLock(async () => {
const err = await ProfileModList.saveModList(profile, mods);
if (err instanceof R2Error) {
Expand Down

0 comments on commit 69cda7c

Please sign in to comment.