Skip to content

Commit

Permalink
make cache file length configurable, ensure it's below 140 - encrypte…
Browse files Browse the repository at this point in the history
…d 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
  • Loading branch information
stoecker committed Sep 6, 2024
1 parent c84585c commit 7eabe1d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/org/openstreetmap/josm/io/CachedFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7eabe1d

Please sign in to comment.