Skip to content

Commit 7eabe1d

Browse files
author
stoecker
committed
make cache file length configurable, ensure it's below 140 - encrypted ext4 seems to have a 143 byte limit, see #23850
git-svn-id: https://josm.openstreetmap.de/svn/trunk@19211 0c6e7542-c601-0410-84e7-c038aed88b3b
1 parent c84585c commit 7eabe1d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/org/openstreetmap/josm/io/CachedFile.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,10 @@ private File checkLocal(URL url) throws IOException {
484484
}
485485

486486
String a = urlStr.replaceAll("[^A-Za-z0-9_.-]", "_");
487-
if (a.length() > 120) {
488-
a = a.substring(0, 100) + "_" + Utils.md5Hex(urlStr);
487+
/* size 11: prefix mirror_ and suffix .tmp */
488+
Integer maxFileLength = Config.getPref().getInt("cache.filename.maxlength", 140)-11;
489+
if (a.length() > maxFileLength) {
490+
a = a.substring(0, maxFileLength-33) + "_" + Utils.md5Hex(urlStr);
489491
}
490492
String localPath = "mirror_" + a;
491493
localPath = truncatePath(destDir, localPath);

0 commit comments

Comments
 (0)