diff --git a/src/org/openstreetmap/josm/io/CachedFile.java b/src/org/openstreetmap/josm/io/CachedFile.java index 73b7623a306..a14353a632e 100644 --- a/src/org/openstreetmap/josm/io/CachedFile.java +++ b/src/org/openstreetmap/josm/io/CachedFile.java @@ -484,8 +484,10 @@ private File checkLocal(URL url) throws IOException { } String a = urlStr.replaceAll("[^A-Za-z0-9_.-]", "_"); - if (a.length() > 120) { - a = a.substring(0, 100) + "_" + Utils.md5Hex(urlStr); + /* size 11: prefix mirror_ and suffix .tmp */ + Integer maxFileLength = Config.getPref().getInt("cache.filename.maxlength", 140)-11; + if (a.length() > maxFileLength) { + a = a.substring(0, maxFileLength-33) + "_" + Utils.md5Hex(urlStr); } String localPath = "mirror_" + a; localPath = truncatePath(destDir, localPath);