Changeset 3877 in josm for trunk


Ignore:
Timestamp:
2011-02-09T12:35:03+01:00 (13 years ago)
Author:
stoecker
Message:

fix input stream mirroring

File:
1 edited

Legend:

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

    r3695 r3877  
    6161                }
    6262            } else {
    63                 file = checkLocal(url, destDir, maxTime);
     63                if(Main.applet) {
     64                    URLConnection conn = url.openConnection();
     65                    conn.setConnectTimeout(5000);
     66                    conn.setReadTimeout(5000);
     67                    fs = new BufferedInputStream(conn.getInputStream());
     68                    file = new File(url.getFile());
     69                } else {
     70                    file = checkLocal(url, destDir, maxTime);
     71                }
    6472            }
    6573        } catch (java.net.MalformedURLException e) {
     
    178186            String[] lp = localPath.split(";");
    179187            file = new File(lp[1]);
    180             if (maxTime <= 0) {
    181                 maxTime = Main.pref.getInteger("mirror.maxtime", 7*24*60*60);
    182             }
    183             if (System.currentTimeMillis() - Long.parseLong(lp[0]) < maxTime*1000) {
    184                 if(file.exists())
     188            if(!file.exists())
     189                file = null;
     190            else {
     191                if (maxTime <= 0) {
     192                    maxTime = Main.pref.getInteger("mirror.maxtime", 7*24*60*60);
     193                }
     194                if (System.currentTimeMillis() - Long.parseLong(lp[0]) < maxTime*1000) {
    185195                    return file;
     196                }
    186197            }
    187198        }
     
    211222                bos.write(buffer, 0, length);
    212223            }
     224            bos.close();
     225            bos = null;
     226            file = new File(destDir, localPath);
     227            destDirFile.renameTo(file);
     228            Main.pref.put(prefKey, System.currentTimeMillis() + ";" + file);
    213229        } finally {
    214230            if (bis != null) {
     
    226242                }
    227243            }
    228             file = new File(destDir, localPath);
    229             destDirFile.renameTo(file);
    230             Main.pref.put(prefKey, System.currentTimeMillis() + ";" + file);
    231244        }
    232245
Note: See TracChangeset for help on using the changeset viewer.