Ignore:
Timestamp:
2012-01-17T17:16:09+01:00 (14 years ago)
Author:
bastiK
Message:

make global cache folder user configurable; move wms cache to global cache folder

File:
1 edited

Legend:

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

    r4811 r4813  
    8282     */
    8383    private File preferencesDirFile = null;
     84    /**
     85     * Internal storage for the cache directory.
     86     */
     87    private File cacheDirFile = null;
    8488
    8589    /**
     
    271275   
    272276    public File getCacheDirectory() {
    273         File cache = new File(getPreferencesDirFile(), "cache");
    274         if (!cache.exists() && !cache.mkdirs()) {
    275             System.err.println(tr("Warning: Failed to create missing cache directory: {0}", cache.getAbsoluteFile()));
     277        if (cacheDirFile != null)
     278            return cacheDirFile;
     279        String path = System.getProperty("josm.cache");
     280        if (path != null) {
     281            cacheDirFile = new File(path).getAbsoluteFile();
     282        } else {
     283            path = Main.pref.get("cache.folder", null);
     284            if (path != null) {
     285                cacheDirFile = new File(path);
     286            } else {
     287                cacheDirFile = new File(getPreferencesDirFile(), "cache");
     288            }
     289        }
     290        if (!cacheDirFile.exists() && !cacheDirFile.mkdirs()) {
     291            System.err.println(tr("Warning: Failed to create missing cache directory: {0}", cacheDirFile.getAbsoluteFile()));
    276292            JOptionPane.showMessageDialog(
    277293                    Main.parent,
    278                     tr("<html>Failed to create missing cache directory: {0}</html>",cache.getAbsoluteFile()),
     294                    tr("<html>Failed to create missing cache directory: {0}</html>", cacheDirFile.getAbsoluteFile()),
    279295                    tr("Error"),
    280296                    JOptionPane.ERROR_MESSAGE
    281297            );
    282298        }
    283         return cache;
     299        return cacheDirFile;
    284300    }
    285301
Note: See TracChangeset for help on using the changeset viewer.