Changeset 19719 in josm for trunk/src/org
- Timestamp:
- 2026-11-29T13:15:13+01:00 (3 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r19707 r19719 388 388 // Backup old preferences if there are old preferences 389 389 if (initSuccessful && prefFile.exists() && prefFile.length() > 0) { 390 checkFileValidity(prefFile, f -> Utils.copyFile(f, backupFile)); 390 checkFileValidity(prefFile, defaults, f -> Utils.copyFile(f, backupFile)); 391 391 } 392 392 … … 400 400 File tmpFile = new File(prefFile + "_tmp"); 401 401 // Only replace the pref file if the _tmp file is valid 402 checkFileValidity(tmpFile, f -> Files.move(f.toPath(), prefFile.toPath(), StandardCopyOption.REPLACE_EXISTING)); 402 checkFileValidity(tmpFile, defaults, f -> Files.move(f.toPath(), prefFile.toPath(), StandardCopyOption.REPLACE_EXISTING)); 403 403 404 404 setCorrectPermissions(prefFile); … … 409 409 * Ensure that a preferences file is "ok" before copying/moving it over another preferences file 410 410 * @param file The file to check 411 * @param defaults {@code true} if the file is the cache file for default preferences 411 412 * @param consumer The consumer that will perform the copy/move action 412 413 * @throws IOException If there is an issue reading/writing the file 413 414 */ 414 private static void checkFileValidity(File file, ThrowingConsumer<File, IOException> consumer) throws IOException { 415 private static void checkFileValidity(File file, boolean defaults, ThrowingConsumer<File, IOException> consumer) throws IOException { 415 416 try { 416 417 // But don't back up if the current preferences are invalid. 417 418 // The validations are expensive (~2/3 CPU, ~1/3 memory), but this isn't a "hot" method 418 419 PreferencesReader.validateXML(file); 419 PreferencesReader reader = new PreferencesReader(file, false);420 PreferencesReader reader = new PreferencesReader(file, defaults); 420 421 reader.parse(); 421 422 consumer.accept(file);
Note:
See TracChangeset
for help on using the changeset viewer.
