From 01065b96cdaf955288b5d0679464f478d7d8918b Mon Sep 17 00:00:00 2001 From: sunjiakun Date: Tue, 24 Dec 2024 10:04:10 +0800 Subject: [PATCH] fix packingTool Signed-off-by: sunjiakun --- adapter/ohos/CompressVerify.java | 4 ++-- .../frameworks/src/json/hap_verify_utils.cpp | 2 +- .../frameworks/src/multiapp_packager.cpp | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/adapter/ohos/CompressVerify.java b/adapter/ohos/CompressVerify.java index 251a46b2..6a4e05c9 100644 --- a/adapter/ohos/CompressVerify.java +++ b/adapter/ohos/CompressVerify.java @@ -589,8 +589,8 @@ public class CompressVerify { * @return isVerifyValidInMultiAppMode if verify valid in multiApp mode. */ private static boolean isVerifyValidInMultiAppMode(Utility utility) { - if (utility.getAppList().isEmpty() && utility.getHapList().isEmpty()) { - LOG.error("CompressVerify::isVerifyValidInMultiAppMode input app-list and hap-list are null."); + if (utility.getAppList().isEmpty() && utility.getHapList().isEmpty() && utility.getHspList().isEmpty()) { + LOG.error("CompressVerify::isVerifyValidInMultiAppMode input app-list, hap-list and hsp-list are null."); return false; } if (!utility.getAppList().isEmpty()) { diff --git a/packing_tool/frameworks/src/json/hap_verify_utils.cpp b/packing_tool/frameworks/src/json/hap_verify_utils.cpp index a4732eb5..93a9eea8 100644 --- a/packing_tool/frameworks/src/json/hap_verify_utils.cpp +++ b/packing_tool/frameworks/src/json/hap_verify_utils.cpp @@ -152,7 +152,7 @@ bool HapVerifyUtils::AppFieldsIsValid(const std::list& hapVerifyI return true; } HapVerifyInfo hap = *hapVerifyInfos.begin(); - for (HapVerifyInfo hapInfo : hapVerifyInfos) { + for (const HapVerifyInfo& hapInfo : hapVerifyInfos) { if (hap.GetVersion().minCompatibleVersionCode != hapInfo.GetVersion().minCompatibleVersionCode || hap.GetApiVersion().targetApiVersion != hapInfo.GetApiVersion().targetApiVersion) { LOGE("hap minCompatibleVersionCode or targetApiVersion different"); diff --git a/packing_tool/frameworks/src/multiapp_packager.cpp b/packing_tool/frameworks/src/multiapp_packager.cpp index 027206c3..6297756a 100644 --- a/packing_tool/frameworks/src/multiapp_packager.cpp +++ b/packing_tool/frameworks/src/multiapp_packager.cpp @@ -335,16 +335,22 @@ bool MultiAppPackager::PrepareFilesForCompression(std::list &fileLi LOGE("MultiAppPackager::CompressAppModeForMultiProject: zipWrapper Open failed!"); return false; } - if (fs::exists(fs::path(outPath).parent_path().parent_path()) && - fs::path(outPath).parent_path().parent_path() != fs::path("/")) { - tempHapDirPath = fs::path(outPath).parent_path().parent_path() / ((Constants::COMPRESSOR_MULTIAPP_TEMP_DIR) + + + char path[PATH_MAX + 1] = {0}; + if (realpath(outPath.c_str(), path) != nullptr && strlen(path < PATH_MAX) { + LOGE("get realpath failed"); + return false; + } + if (fs::exists(fs::path(path).parent_path().parent_path()) && + fs::path(path).parent_path().parent_path() != fs::path("/")) { + tempHapDirPath = fs::path(path).parent_path().parent_path() / ((Constants::COMPRESSOR_MULTIAPP_TEMP_DIR) + Utils::GenerateUUID()); - tempSelectedHapDirPath = fs::path(outPath).parent_path().parent_path() / + tempSelectedHapDirPath = fs::path(path).parent_path().parent_path() / ((Constants::COMPRESSOR_MULTIAPP_TEMP_DIR) + Utils::GenerateUUID()); } else { - tempHapDirPath = fs::path(outPath).parent_path() / ((Constants::COMPRESSOR_MULTIAPP_TEMP_DIR) + + tempHapDirPath = fs::path(path).parent_path() / ((Constants::COMPRESSOR_MULTIAPP_TEMP_DIR) + Utils::GenerateUUID()); - tempSelectedHapDirPath = fs::path(outPath).parent_path() / ((Constants::COMPRESSOR_MULTIAPP_TEMP_DIR) + + tempSelectedHapDirPath = fs::path(path).parent_path() / ((Constants::COMPRESSOR_MULTIAPP_TEMP_DIR) + Utils::GenerateUUID()); } if (!fs::exists(tempHapDirPath)) { -- Gitee