From 18ee94a9f2fa6a4a3ec70ad7fdb07e0db68d9d61 Mon Sep 17 00:00:00 2001 From: Drew Short Date: Mon, 10 Feb 2014 15:06:44 -0500 Subject: [PATCH] Likelihood of over 1.6 million images for comparison in a personal library is likely rare. Improved performance of the thumbnail system by avoiding creating an overwhelming number of sub directories within sub directories to artifically handle a billion billion billion billion billion possbile md5 combinations. There just aren't that many files so it's a waste to presume non-even distribution of md5's such that it would break a filesystem requiring such limiting of directories for storage. --- .../scala/com/sothr/imagetools/image/ImageService.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/sothr/imagetools/image/ImageService.scala b/src/main/scala/com/sothr/imagetools/image/ImageService.scala index d8b9659..1ddf2fb 100644 --- a/src/main/scala/com/sothr/imagetools/image/ImageService.scala +++ b/src/main/scala/com/sothr/imagetools/image/ImageService.scala @@ -79,10 +79,8 @@ object ImageService extends Logging { def calculateThumbPath(md5:String):String = { //break the path down into 4 char parts - val split:List[String] = md5.grouped(3).toList - var dirPath = "" - for (index <- 0 until (split.length-1)) dirPath += split(index) + "/" - var path:String = s"${PropertiesService.get(PropertiesEnum.ThumbnailDirectory.toString)}${PropertiesService.get(PropertiesEnum.ThumbnailSize.toString)}/$dirPath" + val subPath = md5.substring(0, 3) + var path:String = s"${PropertiesService.get(PropertiesEnum.ThumbnailDirectory.toString)}${PropertiesService.get(PropertiesEnum.ThumbnailSize.toString)}/$subPath/" try { val dir = new File(path) if (!dir.exists()) dir.mkdirs()