~ update set token image location

This commit is contained in:
Hans Mackowiak
2025-05-05 19:56:26 +02:00
committed by Chris H
parent 338bb09747
commit 56832ff987
2 changed files with 30 additions and 28 deletions

View File

@@ -102,8 +102,9 @@ public final class ImageKeys {
final String dir; final String dir;
final String filename; final String filename;
String[] tempdata = null;
if (key.startsWith(ImageKeys.TOKEN_PREFIX)) { if (key.startsWith(ImageKeys.TOKEN_PREFIX)) {
String[] tempdata = key.substring(ImageKeys.TOKEN_PREFIX.length()).split("\\|"); tempdata = key.substring(ImageKeys.TOKEN_PREFIX.length()).split("\\|");
String tokenname = tempdata[0] + "_" + tempdata[1]; String tokenname = tempdata[0] + "_" + tempdata[1];
if (tempdata.length > 2) { if (tempdata.length > 2) {
tokenname += "_" + tempdata[2]; tokenname += "_" + tempdata[2];
@@ -150,6 +151,29 @@ public final class ImageKeys {
cachedCards.put(filename, file); cachedCards.put(filename, file);
return file; return file;
} }
if (dir.equals(CACHE_TOKEN_PICS_DIR)) {
String setlessFilename = tempdata[0];
String setCode = tempdata[1];
String collectorNumber = tempdata.length > 2 ? tempdata[2] : "";
if (!collectorNumber.isEmpty()) {
file = findFile(dir, setCode + "/" + collectorNumber + "_" + setlessFilename);
if (file != null) {
cachedCards.put(filename, file);
return file;
}
}
file = findFile(dir, setCode + "/" + setlessFilename);
if (file != null) {
cachedCards.put(filename, file);
return file;
}
file = findFile(dir, setlessFilename);
if (file != null) {
cachedCards.put(filename, file);
return file;
}
}
// AE -> Ae and Ae -> AE for older cards with different file names // AE -> Ae and Ae -> AE for older cards with different file names
// on case-sensitive file systems // on case-sensitive file systems
@@ -231,30 +255,7 @@ public final class ImageKeys {
return file; return file;
} }
} }
if (dir.equals(CACHE_TOKEN_PICS_DIR)) { if (filename.contains("/")) {
String[] tempdata = key.substring(ImageKeys.TOKEN_PREFIX.length()).split("\\|");
String setlessFilename = tempdata[0];
String setCode = tempdata[1];
String collectorNumber = tempdata.length > 2 ? tempdata[2] : "";
if (!collectorNumber.isEmpty()) {
file = findFile(dir, setlessFilename + "_" + setCode + "_" + collectorNumber);
if (file != null) {
cachedCards.put(filename, file);
return file;
}
}
file = findFile(dir, setlessFilename + "_" + setCode);
if (file != null) {
cachedCards.put(filename, file);
return file;
}
file = findFile(dir, setlessFilename);
if (file != null) {
cachedCards.put(filename, file);
return file;
}
} else if (filename.contains("/")) {
String setlessFilename = filename.substring(filename.indexOf('/') + 1); String setlessFilename = filename.substring(filename.indexOf('/') + 1);
file = findFile(dir, setlessFilename); file = findFile(dir, setlessFilename);
if (file != null) { if (file != null) {

View File

@@ -232,11 +232,12 @@ public abstract class ImageFetcher {
String tokenName = tempdata[0]; String tokenName = tempdata[0];
String setCode = tempdata[1]; String setCode = tempdata[1];
StringBuilder sb = new StringBuilder(tokenName); StringBuilder sb = new StringBuilder(setCode);
sb.append("_").append(setCode); sb.append("/");
if (tempdata.length > 2) { if (tempdata.length > 2) {
sb.append("_").append(tempdata[2]); sb.append(tempdata[2]).append("_");
} }
sb.append(tokenName);
sb.append(".jpg"); sb.append(".jpg");
final String filename = sb.toString(); final String filename = sb.toString();