Skip to content

Commit c8c4c0a

Browse files
committed
Final bugfixes before release
1 parent c0df7ff commit c8c4c0a

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

app/constants/action-types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,5 @@ export const actionLabels = {
206206
'DUMMY_ACTION': 'Technical action',
207207
'DEL_DUPLICATECOMMENTS': 'Remove duplicate comments',
208208
'DEL_DUPLICATEMETHODS': 'Remove duplicate methods',
209+
'DEFINE_UPD': 'Update Define-XML properties',
209210
};

app/core/settings.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import clone from 'clone';
2020
import SettingTabs from 'components/settings/tabs.js';
2121
import CdiscLibraryContext from 'constants/cdiscLibraryContext.js';
2222
import { initCdiscLibrary, updateCdiscLibrarySettings, dummyRequest } from 'utils/cdiscLibraryUtils.js';
23+
import saveState from 'utils/saveState.js';
2324
import { updateSettings, openModal, openSnackbar } from 'actions/index.js';
2425
import { encrypt, decrypt } from 'utils/encryptDecrypt.js';
2526

@@ -106,6 +107,8 @@ class ConnectedSettings extends React.Component {
106107
};
107108

108109
makeBackup = () => {
110+
// Save state without writing any current Define-XML changes
111+
saveState('noWrite');
109112
ipcRenderer.send('makeBackup', this.state.settings.backup);
110113
};
111114

app/main/validateState.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,24 @@ const validateState = async (options = {}) => {
3939
let fileData = await readFile(pathToState);
4040
let state = JSON.parse(fileData);
4141

42+
let ctPathUpdated = false;
4243
let missingFiles = { defines: [], ct: [] };
4344

4445
// Check for missing CT
4546
if (state && state.controlledTerminology && state.controlledTerminology.byId) {
4647
await Promise.all(Object.values(state.controlledTerminology.byId).map(async (ct) => {
4748
// Check if file exists;
48-
if (!await isAccessible(path.join(pathToUserData, 'controlledTerminology', ct.id + '.nogz'))) {
49+
let pathToCurrentCt = path.join(pathToUserData, 'controlledTerminology', path.basename(ct.pathToFile));
50+
if (!await isAccessible(pathToCurrentCt)) {
4951
missingFiles.ct.push(ct.id);
5052
if (cleanCodeLists) {
5153
delete state.controlledTerminology.byId[ct.id];
5254
state.controlledTerminology.allIds.splice(state.controlledTerminology.allIds.indexOf(ct.id), 1);
5355
}
56+
} else if (ct.pathToFile !== pathToCurrentCt) {
57+
// Path can change if loading for a different user/computer
58+
ct.pathToFile = pathToCurrentCt;
59+
ctPathUpdated = true;
5460
}
5561
}));
5662
} else {
@@ -88,8 +94,8 @@ const validateState = async (options = {}) => {
8894
}
8995
}
9096

91-
if ((cleanCodeLists && missingFiles.ct.length > 0) || (cleanDefines && missingFiles.defines.length > 0)) {
92-
await writeFile(pathToState, JSON.stringify(state));
97+
if ((cleanCodeLists && missingFiles.ct.length > 0) || (cleanDefines && missingFiles.defines.length > 0) || ctPathUpdated) {
98+
await writeFile(pathToState, JSON.stringify(state, null, 4));
9399
}
94100
return { passed: true, issues: missingFiles.defines.concat(missingFiles.ct) };
95101
} catch (error) {

0 commit comments

Comments
 (0)