Changeset 4813 in josm for trunk/src/org/openstreetmap


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

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

Location:
trunk/src/org/openstreetmap/josm/data
Files:
2 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
  • trunk/src/org/openstreetmap/josm/data/imagery/WmsCache.java

    r4745 r4813  
    5353    //TODO Do loading from partial cache and downloading at the same time, don't wait for partical cache to load
    5454
    55     private static final StringProperty PROP_CACHE_PATH = new StringProperty("imagery.wms-cache.path", "wms-cache");
     55    private static final StringProperty PROP_CACHE_PATH = new StringProperty("imagery.wms-cache.path", new File(Main.pref.getCacheDirectory(), "wms").getPath());
    5656    private static final String INDEX_FILENAME = "index.xml";
    5757    private static final String LAYERS_INDEX_FILENAME = "layers.properties";
     
    100100        if (!(cPath.startsWith("/") || cPath.startsWith(":/",1))) {
    101101            //Not an absolute path
    102             cPath = Main.pref.getPreferencesDir() + cPath;
     102            cPath = Main.pref.getCacheDirectory() + cPath;
    103103        }
    104104        return cPath;
Note: See TracChangeset for help on using the changeset viewer.