Changeset 4128 in josm


Ignore:
Timestamp:
2011-06-08T09:06:48+02:00 (10 years ago)
Author:
stoecker
Message:

mirrored data is used twice as long in case of loading errors

File:
1 edited

Legend:

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

    r4022 r4128  
    183183    private File checkLocal(URL url, String destDir, long maxTime) throws IOException {
    184184        String prefKey = getPrefKey(url, destDir);
     185        long age = 0L;
    185186        File file = null;
    186187        // FIXME: replace with normal getCollection after july 2011
     
    195196                    maxTime = Main.pref.getInteger("mirror.maxtime", 7*24*60*60);
    196197                }
    197                 if (System.currentTimeMillis() - Long.parseLong(lp[0]) < maxTime*1000) {
     198                age = System.currentTimeMillis() - Long.parseLong(lp[0]);
     199                if (age < maxTime*1000) {
    198200                    return file;
    199201                }
     
    231233            Main.pref.putCollection(prefKey, Arrays.asList(new String[]
    232234            {Long.toString(System.currentTimeMillis()), file.toString()}));
     235        } catch (IOException e) {
     236            if (age > maxTime*1000 && age < maxTime*1000*2) {
     237                System.out.println(tr("Failed to load {0}, use cached file and retry next time: {1}",
     238                url, e));
     239                return file;
     240            } else {
     241                throw e;
     242            }
    233243        } finally {
    234244            if (bis != null) {
Note: See TracChangeset for help on using the changeset viewer.