fix change generated thumbnail directory
@@ -77,7 +77,7 @@ public class ThumbnailManager {
protected String imageExtention = "png";
- protected int splitSize = 3;
+ protected int splitSize = 5;
protected int thumbnailTaskQueueSize = 10000;
@@ -87,6 +87,8 @@ public class ThumbnailManager {
protected long noImageExpired = 24 * 60 * 60 * 1000L; // 24 hours
+ protected int splitHashSize = 10;
+
@PostConstruct
public void init() {
if (logger.isDebugEnabled()) {
@@ -299,13 +301,11 @@ public class ThumbnailManager {
protected String getImageFilename(final String docid) {
final StringBuilder buf = new StringBuilder(50);
- for (int i = 0; i < docid.length(); i++) {
- if (i > 0 && i % splitSize == 0) {
- buf.append('/');
- }
- buf.append(docid.charAt(i));
+ for (int i = 0; i < docid.length(); i += splitSize) {
+ final int hash = docid.substring(i).hashCode() % splitHashSize;
+ buf.append('_').append(Integer.toString(hash)).append('/');
}
- buf.append('.').append(imageExtention);
+ buf.append(docid).append('.').append(imageExtention);
return buf.toString();
}
@@ -494,6 +494,7 @@ public class ThumbnailManager {
paths.filter(path -> path.toFile().getName().endsWith(imageExtention)).forEach(path -> {
final Path subPath = basePath.relativize(path);
final String docId = subPath.toString().replace("/", StringUtil.EMPTY).replace(suffix, StringUtil.EMPTY);
+ if (!docId.startsWith("_")) {
final String filename = getImageFilename(docId);
final Path newPath = basePath.resolve(filename);
if (!path.equals(newPath)) {
@@ -509,6 +510,7 @@ public class ThumbnailManager {
logger.warn("Failed to move {}", path, e);
}
}
+ }
});
} catch (final IOException e) {
logger.warn("Failed to migrate thumbnail images.", e);
@@ -536,4 +538,8 @@ public class ThumbnailManager {
this.noImageExpired = noImageExpired;
}
+ public void setSplitHashSize(int splitHashSize) {
+ this.splitHashSize = splitHashSize;
+ }
+
}
