From cc24af1f232dd22507aeb018895d1a0ec4e9b4ea Mon Sep 17 00:00:00 2001 From: ma_nan Date: Thu, 9 Sep 2021 14:42:52 +0800 Subject: [PATCH] fix bug Signed-off-by: ma_nan --- services/applypatch/block_set.cpp | 2 +- services/applypatch/transfer_manager.cpp | 4 ++-- services/include/applypatch/transfer_manager.h | 1 + services/updater_binary/update_image_block.cpp | 5 +++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/services/applypatch/block_set.cpp b/services/applypatch/block_set.cpp index b1670a93..b267cfb7 100644 --- a/services/applypatch/block_set.cpp +++ b/services/applypatch/block_set.cpp @@ -228,7 +228,7 @@ int32_t BlockSet::LoadSourceBuffer(const Command &cmd, size_t &pos, std::vector< LOG(INFO) << "new start to read source block ..."; UPDATER_CHECK_ONLY_RETURN(srcBlk.ReadDataFromBlock(cmd.GetFileDescriptor(), sourceBuffer) > 0, return -1); std::string nextArgv = cmd.GetArgumentByPos(pos++); - UPDATER_CHECK_ONLY_RETURN(nextArgv != "", return 0); + UPDATER_CHECK_ONLY_RETURN(nextArgv != "", return 1); BlockSet locations; locations.ParserAndInsert(nextArgv); MoveBlock(sourceBuffer, locations, sourceBuffer); diff --git a/services/applypatch/transfer_manager.cpp b/services/applypatch/transfer_manager.cpp index e98cddb5..00d88b48 100644 --- a/services/applypatch/transfer_manager.cpp +++ b/services/applypatch/transfer_manager.cpp @@ -116,7 +116,7 @@ void TransferManager::Init() bool TransferManager::RegisterForRetry(const std::string &cmd) { - std::string path = globalParams->storeBase + "/" + "retry_flag"; + std::string path = globalParams->retryFile; int fd = open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); UPDATER_ERROR_CHECK(fd != -1, "Failed to create", return false); UPDATER_ERROR_CHECK(fchown(fd, O_USER_GROUP_ID, O_USER_GROUP_ID) == 0, @@ -130,7 +130,7 @@ bool TransferManager::RegisterForRetry(const std::string &cmd) std::string TransferManager::ReloadForRetry() const { - std::string path = globalParams->storeBase + "/" + "retry_flag"; + std::string path = globalParams->retryFile; int fd = open(path.c_str(), O_RDONLY); UPDATER_ERROR_CHECK(fd >= 0, "Failed to open", return ""); (void)lseek(fd, 0, SEEK_SET); diff --git a/services/include/applypatch/transfer_manager.h b/services/include/applypatch/transfer_manager.h index 4d63a04d..3231917f 100644 --- a/services/include/applypatch/transfer_manager.h +++ b/services/include/applypatch/transfer_manager.h @@ -50,6 +50,7 @@ struct TransferParams { std::unique_ptr writerThreadInfo; int storeCreated; std::string storeBase; + std::string retryFile; uint8_t *patchDataBuffer; size_t patchDataSize; }; diff --git a/services/updater_binary/update_image_block.cpp b/services/updater_binary/update_image_block.cpp index 4e049fd2..cd042792 100644 --- a/services/updater_binary/update_image_block.cpp +++ b/services/updater_binary/update_image_block.cpp @@ -167,13 +167,14 @@ static int32_t GetUpdateBlockInfo(struct UpdateBlockInfo &infos, uscript::UScrip } static int32_t ExecuteTransferCommand(int fd, const std::vector &lines, uscript::UScriptEnv &env, - uscript::UScriptContext &context) + uscript::UScriptContext &context, const std::string &partitionName) { TransferManagerPtr tm = TransferManager::GetTransferManagerInstance(); auto globalParams = tm->GetGlobalParams(); auto writerThreadInfo = globalParams->writerThreadInfo.get(); globalParams->storeBase = "/data/updater/update_tmp"; + globalParams->retryFile = std::string("/data/updater") + partitionName + "_retry"; LOG(INFO) << "Store base path is " << globalParams->storeBase; int32_t ret = Store::CreateNewSpace(globalParams->storeBase, !globalParams->env->IsRetry()); UPDATER_ERROR_CHECK(ret != -1, "Error to create new store space", @@ -247,7 +248,7 @@ static int32_t DoExecuteUpdateBlock(UpdateBlockInfo &infos, uscript::UScriptEnv int fd = open(infos.devPath.c_str(), O_RDWR | O_LARGEFILE); UPDATER_ERROR_CHECK (fd != -1, "Failed to open block", env.GetPkgManager()->ClosePkgStream(outStream); return USCRIPT_ERROR_EXECUTE); - int32_t ret = ExecuteTransferCommand(fd, lines, env, context); + int32_t ret = ExecuteTransferCommand(fd, lines, env, context, infos.partitionName); fsync(fd); close(fd); fd = -1; -- Gitee