Changeset 4810 in josm for trunk/src/org


Ignore:
Timestamp:
2012-01-17T14:09:10+01:00 (12 years ago)
Author:
bastiK
Message:

move cache files to ~/.josm/cache (only CacheCustomContent)

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r4770 r4810  
    268268    public File getPluginsDirectory() {
    269269        return new File(getPreferencesDirFile(), "plugins");
     270    }
     271   
     272    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()));
     276            JOptionPane.showMessageDialog(
     277                    Main.parent,
     278                    tr("<html>Failed to create missing cache directory: {0}</html>",cache.getAbsoluteFile()),
     279                    tr("Error"),
     280                    JOptionPane.ERROR_MESSAGE
     281            );
     282        }
     283        return cache;
    270284    }
    271285
  • trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java

    r4709 r4810  
    7878        this.ident = ident;
    7979        this.updateInterval = updateInterval;
    80         this.path = new File(Main.pref.getPreferencesDir(), ident);
     80        this.path = new File(Main.pref.getCacheDirectory(), ident);
    8181    }
    8282
     
    8686     */
    8787    public byte[] updateIfRequired() throws T {
    88         if(Main.pref.getInteger("cache." + ident, 0) + updateInterval < new Date().getTime()/1000
     88        if (Main.pref.getInteger("cache." + ident, 0) + updateInterval < new Date().getTime()/1000
    8989                || !isCacheValid())
    9090            return updateForce();
     
    9797     */
    9898    public String updateIfRequiredString() throws T {
    99         if(Main.pref.getInteger("cache." + ident, 0) + updateInterval < new Date().getTime()/1000
     99        if (Main.pref.getInteger("cache." + ident, 0) + updateInterval < new Date().getTime()/1000
    100100                || !isCacheValid())
    101101            return updateForceString();
     
    121121        updateForce();
    122122        try {
    123             return new String(data,"utf-8");
    124         } catch(UnsupportedEncodingException e){
     123            return new String(data, "utf-8");
     124        } catch (UnsupportedEncodingException e){
    125125            e.printStackTrace();
    126126            return "";
     
    133133     */
    134134    public byte[] getData() throws T {
    135         if(data == null) {
     135        if (data == null) {
    136136            loadFromDisk();
    137137        }
     
    156156     */
    157157    private void loadFromDisk() throws T {
    158         if(Main.applet)
     158        if (Main.applet)
    159159            this.data = updateForce();
    160160        else {
     
    164164                input.read(this.data);
    165165                input.close();
    166             } catch(IOException e) {
     166            } catch (IOException e) {
    167167                this.data = updateForce();
    168168            }
     
    174174     */
    175175    private void saveToDisk() {
    176         if(Main.applet)
     176        if (Main.applet)
    177177            return;
    178178        try {
Note: See TracChangeset for help on using the changeset viewer.