Changeset 19719 in josm for trunk/src/org


Ignore:
Timestamp:
2026-11-29T13:15:13+01:00 (3 days ago)
Author:
stoecker
Message:

fix #25147 - Default preferences cache is never saved - patch by wangi

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r19707 r19719  
    388388        // Backup old preferences if there are old preferences
    389389        if (initSuccessful && prefFile.exists() && prefFile.length() > 0) {
    390             checkFileValidity(prefFile, f -> Utils.copyFile(f, backupFile));
     390            checkFileValidity(prefFile, defaults, f -> Utils.copyFile(f, backupFile));
    391391        }
    392392
    … …  
    400400        File tmpFile = new File(prefFile + "_tmp");
    401401        // 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));
    403403
    404404        setCorrectPermissions(prefFile);
    … …  
    409409     * Ensure that a preferences file is "ok" before copying/moving it over another preferences file
    410410     * @param file The file to check
     411     * @param defaults {@code true} if the file is the cache file for default preferences
    411412     * @param consumer The consumer that will perform the copy/move action
    412413     * @throws IOException If there is an issue reading/writing the file
    413414     */
    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 {
    415416        try {
    416417            // But don't back up if the current preferences are invalid.
    417418            // The validations are expensive (~2/3 CPU, ~1/3 memory), but this isn't a "hot" method
    418419            PreferencesReader.validateXML(file);
    419             PreferencesReader reader = new PreferencesReader(file, false);
     420            PreferencesReader reader = new PreferencesReader(file, defaults);
    420421            reader.parse();
    421422            consumer.accept(file);
Note: See TracChangeset for help on using the changeset viewer.