SiliCompressor
SiliCompressor copied to clipboard
The compressed file was the same when using multi-thread.
In my case :
- Choose 9 images .
- Create 9 thread to compress images.
- Some compressed file was same ( !!! this is wrong).
What wrong ? When I debug the code, I find the compressed cache file name was same :
-
The files before compressed
-
The files after compressed
I guess the author did not consider the situation when the multi-thread start at the same time.
The issue was caused by the code below:
com.iceteck.silicompressorr.SiliCompressor line: 223
/**
* Get the file path of the compressed file
*
* @param filename
* @param file Destination directory
* @return
*/
private String getFilename(String filename, File file) {
if (!file.exists()) {
file.mkdirs();
}
String ext = ".jpg";
//get extension
/*if (Pattern.matches("^[.][p][n][g]", filename)){
ext = ".png";
}*/
return (file.getAbsolutePath() + "/IMG_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ext);
}