svn commit: r1604554 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1604554 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java

jleroux@apache.org
Author: jleroux
Date: Sun Jun 22 09:18:39 2014
New Revision: 1604554

URL: http://svn.apache.org/r1604554
Log:
A proposed fix by chunlinyao for "checkExistsImage method in ImageManagementServices" at https://issues.apache.org/jira/browse/OFBIZ-5658

I think indexOf(".") in these code should be lastIndexOf(".").
From CATALOG -> Image Management -> Upload view. upload some Images it will call this method. This method is intended to add (count) to the image name, when the file name was already exist. I debugged in it, the imagePath was the absolute path of the image file. So If any parent folder name contains "." , it will not works correctly.

chunlinyao's Note: And after review the whole ImageManagementServices.java file. I found it use static variables (ex. imageCount imagePath). It is not thread safe.

Modified:
    ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java?rev=1604554&r1=1604553&r2=1604554&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java Sun Jun 22 09:18:39 2014
@@ -780,8 +780,8 @@ public class ImageManagementServices {
             return file;
         }
         imageCount++;
-        String filePath = imagePath.substring(0, imagePath.indexOf("."));
-        String type = imagePath.substring(imagePath.indexOf(".") + 1);
+        String filePath = imagePath.substring(0, imagePath.lastIndexOf("."));
+        String type = imagePath.substring(imagePath.lastIndexOf(".") + 1);
         file = new File(filePath + "(" + imageCount + ")." + type);
         return checkExistsImage(file);
     }