Ignore:
Timestamp:
2017-09-14T16:19:17+02:00 (7 years ago)
Author:
bastiK
Message:

see #15229 - fix bug where parameter createIfMissing would be ignored because of caching

File:
1 edited

Legend:

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

    r12856 r12857  
    340340    @Override
    341341    public File getPreferencesDirectory(boolean createIfMissing) {
    342         if (preferencesDir != null)
    343             return preferencesDir;
    344         String path;
    345         path = System.getProperty("josm.pref");
    346         if (path != null) {
    347             preferencesDir = new File(path).getAbsoluteFile();
    348         } else {
    349             path = System.getProperty("josm.home");
     342        if (preferencesDir == null) {
     343            String path;
     344            path = System.getProperty("josm.pref");
    350345            if (path != null) {
    351346                preferencesDir = new File(path).getAbsoluteFile();
    352347            } else {
    353                 preferencesDir = Main.platform.getDefaultPrefDirectory();
     348                path = System.getProperty("josm.home");
     349                if (path != null) {
     350                    preferencesDir = new File(path).getAbsoluteFile();
     351                } else {
     352                    preferencesDir = Main.platform.getDefaultPrefDirectory();
     353                }
    354354            }
    355355        }
     
    380380    @Override
    381381    public File getUserDataDirectory(boolean createIfMissing) {
    382         if (userdataDir != null)
    383             return userdataDir;
    384         String path;
    385         path = System.getProperty("josm.userdata");
    386         if (path != null) {
    387             userdataDir = new File(path).getAbsoluteFile();
    388         } else {
    389             path = System.getProperty("josm.home");
     382        if (userdataDir == null) {
     383            String path;
     384            path = System.getProperty("josm.userdata");
    390385            if (path != null) {
    391386                userdataDir = new File(path).getAbsoluteFile();
    392387            } else {
    393                 userdataDir = Main.platform.getDefaultUserDataDirectory();
     388                path = System.getProperty("josm.home");
     389                if (path != null) {
     390                    userdataDir = new File(path).getAbsoluteFile();
     391                } else {
     392                    userdataDir = Main.platform.getDefaultUserDataDirectory();
     393                }
    394394            }
    395395        }
     
    445445    @Override
    446446    public File getCacheDirectory(boolean createIfMissing) {
    447         if (cacheDir != null)
    448             return cacheDir;
    449         String path = System.getProperty("josm.cache");
    450         if (path != null) {
    451             cacheDir = new File(path).getAbsoluteFile();
    452         } else {
    453             path = System.getProperty("josm.home");
     447        if (cacheDir == null) {
     448            String path = System.getProperty("josm.cache");
    454449            if (path != null) {
    455                 cacheDir = new File(path, "cache");
     450                cacheDir = new File(path).getAbsoluteFile();
    456451            } else {
    457                 path = get("cache.folder", null);
     452                path = System.getProperty("josm.home");
    458453                if (path != null) {
    459                     cacheDir = new File(path).getAbsoluteFile();
     454                    cacheDir = new File(path, "cache");
    460455                } else {
    461                     cacheDir = Main.platform.getDefaultCacheDirectory();
     456                    path = get("cache.folder", null);
     457                    if (path != null) {
     458                        cacheDir = new File(path).getAbsoluteFile();
     459                    } else {
     460                        cacheDir = Main.platform.getDefaultCacheDirectory();
     461                    }
    462462                }
    463463            }
Note: See TracChangeset for help on using the changeset viewer.