Changeset 4022 in josm


Ignore:
Timestamp:
Apr 14, 2011 6:11:06 PM (2 years ago)
Author:
stoecker
Message:

fix prefs key for mirrored input stream, use pref collection instead of own code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java

    r3877 r4022  
    1313import java.net.URL; 
    1414import java.net.URLConnection; 
     15import java.util.Arrays; 
     16import java.util.Collection; 
    1517import java.util.Enumeration; 
    1618import java.util.zip.ZipEntry; 
     
    146148            { 
    147149                String prefKey = getPrefKey(url, destDir); 
    148                 String localPath = Main.pref.get(prefKey); 
    149                 if (localPath != null && localPath.length() > 0) 
    150                 { 
    151                     String[] lp = localPath.split(";"); 
     150                // FIXME: replace with normal getCollection after july 2011 
     151                Collection<String> localPath = Main.pref.getCollectionOld(prefKey, ";"); 
     152                if(localPath.size() == 2) { 
     153                    String[] lp = (String[]) localPath.toArray(); 
    152154                    File lfile = new File(lp[1]); 
    153155                    if(lfile.exists()) { 
     
    176178        } 
    177179        prefKey.append(url.toString()); 
    178         return prefKey.toString(); 
     180        return prefKey.toString().replaceAll("=","_"); 
    179181    } 
    180182 
    181183    private File checkLocal(URL url, String destDir, long maxTime) throws IOException { 
    182184        String prefKey = getPrefKey(url, destDir); 
    183         String localPath = Main.pref.get(prefKey); 
    184185        File file = null; 
    185         if (localPath != null && localPath.length() > 0) { 
    186             String[] lp = localPath.split(";"); 
     186        // FIXME: replace with normal getCollection after july 2011 
     187        Collection<String> localPathEntry = Main.pref.getCollectionOld(prefKey, ";"); 
     188        if(localPathEntry.size() == 2) { 
     189            String[] lp = (String[]) localPathEntry.toArray(); 
    187190            file = new File(lp[1]); 
    188191            if(!file.exists()) 
     
    207210 
    208211        String a = url.toString().replaceAll("[^A-Za-z0-9_.-]", "_"); 
    209         localPath = "mirror_" + a; 
     212        String localPath = "mirror_" + a; 
    210213        destDirFile = new File(destDir, localPath + ".tmp"); 
    211214        BufferedOutputStream bos = null; 
     
    226229            file = new File(destDir, localPath); 
    227230            destDirFile.renameTo(file); 
    228             Main.pref.put(prefKey, System.currentTimeMillis() + ";" + file); 
     231            Main.pref.putCollection(prefKey, Arrays.asList(new String[] 
     232            {Long.toString(System.currentTimeMillis()), file.toString()})); 
    229233        } finally { 
    230234            if (bis != null) { 
Note: See TracChangeset for help on using the changeset viewer.