2024年07月19日 1.0.2 优化MD5校验不过,删除后再下载

main
gaoshuguang 1 year ago
parent f918f7cf69
commit 6ecf25838c

@ -74,7 +74,8 @@ public class MyEnvironmentPostProcessor implements EnvironmentPostProcessor {
break; break;
} }
String resultName=new String(properties.getProperty("DownloadPath").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); String resultName=new String(properties.getProperty("DownloadPath").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
properties.setProperty("DownloadPath", resultName+File.separator + "DownloadFilePath"); //properties.setProperty("DownloadPath", resultName+File.separator + "DownloadFilePath");
properties.setProperty("DownloadPath", resultName);
//properties.setProperty("DownloadPath", properties.getProperty("DownloadPath") + File.separator + "DownloadFilePath"); //properties.setProperty("DownloadPath", properties.getProperty("DownloadPath") + File.separator + "DownloadFilePath");
properties.setProperty("socketPort", Newproperties.getProperty("socketPort")); properties.setProperty("socketPort", Newproperties.getProperty("socketPort"));
//下发文件存放时间(天) //下发文件存放时间(天)

@ -84,13 +84,23 @@ public class MD5Util {
* @date 2022-10-16 13:30 * @date 2022-10-16 13:30
*/ */
public static String getMd5ByFilePath(String filePath) { public static String getMd5ByFilePath(String filePath) {
String value = null; String value = null;
FileInputStream fileInputStream =null;
try { try {
value = DigestUtils.md5DigestAsHex(new FileInputStream(filePath)); fileInputStream=new FileInputStream(filePath);
value = DigestUtils.md5DigestAsHex(fileInputStream);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
finally {
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}
return value; return value;
} }

@ -105,6 +105,7 @@ public class DownAndCallBackServiceImpl implements DownAndCallBackService {
String downMd5 = MD5Util.getMd5ByFilePath(DownloadPath + File.separator + zlibName); String downMd5 = MD5Util.getMd5ByFilePath(DownloadPath + File.separator + zlibName);
log.info("[uuid:{}]-下载文件{}MD5值:{},原MD5值为:{}", uuid, zlibName, downMd5, md5); log.info("[uuid:{}]-下载文件{}MD5值:{},原MD5值为:{}", uuid, zlibName, downMd5, md5);
if (StringUtils.isBlank(downMd5) || !md5.equals(downMd5)) { if (StringUtils.isBlank(downMd5) || !md5.equals(downMd5)) {
FileUtil.delete(new File(DownloadPath + File.separator + zlibName));
log.error("[uuid:{}]-下载文件({}){},MD5校验失败", uuid, protocolType, zlibName); log.error("[uuid:{}]-下载文件({}){},MD5校验失败", uuid, protocolType, zlibName);
} else { } else {
log.info("[uuid:{}]-{}下载文件:{}完成MD5值校验成功", uuid, staName, zlibName); log.info("[uuid:{}]-{}下载文件:{}完成MD5值校验成功", uuid, staName, zlibName);

@ -1,4 +1,4 @@
序号 日期 版本号 说明 序号 日期 版本号 说明
1 2023年08月18日 1.0.0 初始版本号开放道下发分中心程序存放指定的文件路径下程序写入CMS_PARAMETER分中心任务表即可 1 2023年08月18日 1.0.0 初始版本号开放道下发分中心程序存放指定的文件路径下程序写入CMS_PARAMETER分中心任务表即可
2 2024年07月01日 1.0.1 优化 2 2024年07月01日 1.0.1 优化
3 2024年07月19日 1.0.2 优化MD5校验不过删除后再下载
Loading…
Cancel
Save