Skip to content

Commit 41228e2

Browse files
committed
chore: corrupt preferences auto reset
1 parent f1dd190 commit 41228e2

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

src/brackets.js

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -361,34 +361,19 @@ define(function (require, exports, module) {
361361
if (PreferencesManager._isUserScopeCorrupt()) {
362362
const userPrefFullPath = PreferencesManager.getUserPrefFile();
363363
// user scope can get corrupt only if the file exists, is readable,
364-
// but malformed. no need to check for its existance.
365-
const info = MainViewManager.findInAllWorkingSets(userPrefFullPath);
366-
let paneId;
367-
if (info.length) {
368-
paneId = info[0].paneId;
369-
}
364+
// but malformed. no need to check for its existence.
370365
Metrics.countEvent(Metrics.EVENT_TYPE.STORAGE, "prefs.corrupt", "startup");
371-
FileViewController.openFileAndAddToWorkingSet(userPrefFullPath, paneId)
372-
.done(function () {
373-
Dialogs.showModalDialog(
374-
DefaultDialogs.DIALOG_ID_ERROR,
375-
Strings.ERROR_PREFS_CORRUPT_TITLE,
376-
Strings.ERROR_PREFS_CORRUPT
377-
).done(function () {
378-
// give the focus back to the editor with the pref file
379-
MainViewManager.focusActivePane();
380-
});
381-
});
366+
let file = FileSystem.getFileForPath(userPrefFullPath);
367+
file.unlinkAsync().finally(function () {
368+
Dialogs.showModalDialog(
369+
DefaultDialogs.DIALOG_ID_ERROR,
370+
Strings.ERROR_PREFS_RESET_TITLE,
371+
Strings.ERROR_PREFS_CORRUPT_RESET
372+
);
373+
});
382374
}
383375
});
384376
});
385-
386-
// See if any startup files were passed to the application
387-
if (brackets.app.getPendingFilesToOpen) {
388-
brackets.app.getPendingFilesToOpen(function (err, paths) {
389-
DragAndDrop.openDroppedFiles(paths);
390-
});
391-
}
392377
});
393378
});
394379
}

src/nls/root/strings.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,11 @@ define({
114114

115115
// Application preferences corrupt error strings
116116
"ERROR_PREFS_CORRUPT_TITLE": "Error Reading Preferences",
117+
"ERROR_PREFS_RESET_TITLE": "Settings Reset - Restart Required",
117118
"ERROR_PREFS_PROJECT_LINT": "Project Preferences",
118119
"ERROR_PREFS_PROJECT_LINT_MESSAGE": "Error: The project contains both `.brackets.json` and `.phcode.json` files, causing a conflict. Please delete either `.brackets.json` or `.phcode.json` and then reload the project.",
119120
"ERROR_PREFS_CORRUPT": "Your preferences file is not valid JSON. The file will be opened so that you can correct the format. You will need to restart {APP_NAME} for the changes to take effect.",
121+
"ERROR_PREFS_CORRUPT_RESET": "Your {APP_NAME} settings were damaged and have been reset. Please restart {APP_NAME} for the changes to take effect.",
120122
"ERROR_PROJ_PREFS_CORRUPT": "Your project preferences file is not valid JSON. The file will be opened so that you can correct the format. You will need to reload the project for the changes to take effect.",
121123

122124
// Application error strings

0 commit comments

Comments
 (0)