From 4fc209982140bc6fca77265aa93c97430817fcb6 Mon Sep 17 00:00:00 2001 From: Lotol Date: Thu, 18 May 2023 02:24:42 +0000 Subject: [PATCH 1/4] fixed c672b6f from https://gitee.com/lotol/developtools_packing_tool/pulls/531 update adapter/ohos/Compressor.java. Signed-off-by: Lotol --- adapter/ohos/Compressor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapter/ohos/Compressor.java b/adapter/ohos/Compressor.java index 3382df1b..b3f6983c 100644 --- a/adapter/ohos/Compressor.java +++ b/adapter/ohos/Compressor.java @@ -479,7 +479,7 @@ public class Compressor { } private static byte[] checkSum(String filename) throws BundleException { - try (InputStream fis = new FileInputStream(filename)){ + try (InputStream fis = new FileInputStream(filename)) { byte[] buffer = new byte[BUFFER_BYTE_SIZE]; MessageDigest complete = MessageDigest.getInstance(SHA_256); int numRead; -- Gitee From ba27e550fe3b209951671afd06e7e4c0c2aec332 Mon Sep 17 00:00:00 2001 From: zhaogan Date: Thu, 25 May 2023 11:26:56 +0800 Subject: [PATCH 2/4] fixed 757d22c from https://gitee.com/zhaogan0603/developtools_packing_tool/pulls/536 Issue: #I787QI Description:Fixed probabilistic packaging failure Sig: SIG_ApplicaitonFramework Feature or Bugfix: Bugfix Binary Source: No Signed-off-by: zhaogan --- adapter/ohos/Compressor.java | 48 ++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/adapter/ohos/Compressor.java b/adapter/ohos/Compressor.java index b3f6983c..f54485ca 100644 --- a/adapter/ohos/Compressor.java +++ b/adapter/ohos/Compressor.java @@ -357,8 +357,37 @@ public class Compressor { } } + private static boolean hasGenerateBuildHash(Utility utility) throws BundleException { + File file = new File(utility.getJsonPath()); + if (!file.exists()) { + LOG.error("Compressor::hasGenerateBuildHash failed for json file not exist"); + throw new BundleException("Compressor::hasGenerateBuildHash failed for json file not exist"); + } + InputStream json = null; + boolean res = false; + try { + json = new FileInputStream(file); + JSONObject jsonObject = JSON.parseObject(json, JSONObject.class); + if (!jsonObject.containsKey(APP) || !jsonObject.containsKey(MODULE)) { + LOG.error("json file is invalid."); + throw new BundleException("json file is invalid."); + } + JSONObject appJson = jsonObject.getJSONObject(APP); + JSONObject moduleJson = jsonObject.getJSONObject(MODULE); + if (appJson.containsKey(GENERATE_BUILD_HASH) || moduleJson.containsKey(GENERATE_BUILD_HASH)) { + res = true; + } + } catch (BundleException | IOException exception) { + LOG.error("Compressor::hasGenerateBuildHash failed."); + throw new BundleException("Compressor::hasGenerateBuildHash failed."); + } finally { + FileUtils.closeStream(json); + } + return res; + } + private static void setGenerateBuildHash(Utility utility) throws BundleException { - if (utility.isBuildHashFinish()) { + if (utility.isBuildHashFinish() || !hasGenerateBuildHash(utility)) { return; } copyFileToTempDir(utility); @@ -449,11 +478,6 @@ public class Compressor { private static void buildHash(Utility utility) throws BundleException { if (utility.isBuildHashFinish() || (!utility.getGenerateBuildHash())) { - deleteTempFileForHash(utility); - return; - } - // check whether a hash value needs to be generated - if (!utility.getGenerateBuildHash()) { return; } String filePath = utility.getOutPath(); @@ -466,18 +490,6 @@ public class Compressor { } } - private static void deleteTempFileForHash(Utility utility) throws BundleException { - try { - String jsonPath = utility.getJsonPath(); - File jsonFile = new File(jsonPath); - File tempFile = jsonFile.getParentFile(); - deleteFile(tempFile.getCanonicalPath()); - } catch (IOException e) { - LOG.error("Compressor::deleteTempFileForHash failed, " + e.getMessage()); - throw new BundleException("Compressor::deleteTempFileForHash failed."); - } - } - private static byte[] checkSum(String filename) throws BundleException { try (InputStream fis = new FileInputStream(filename)) { byte[] buffer = new byte[BUFFER_BYTE_SIZE]; -- Gitee From f08aca58808c2b6c8aa78449d95aea6bf042629e Mon Sep 17 00:00:00 2001 From: zhaogan Date: Fri, 26 May 2023 16:11:38 +0800 Subject: [PATCH 3/4] fixed 3d246de from https://gitee.com/zhaogan0603/developtools_packing_tool/pulls/539 Issue: #I78NCY Description:Fix README Sig: SIG_ApplicaitonFramework Feature or Bugfix: Bugfix Binary Source: No Signed-off-by: zhaogan --- README_zh.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README_zh.md b/README_zh.md index 4e6bcb39..055e387c 100644 --- a/README_zh.md +++ b/README_zh.md @@ -56,7 +56,7 @@ java -jar app_packing_tool.jar --mode hap --json-path