From 489376614a9a6359feb1fd7ca5b42aa09953b86a Mon Sep 17 00:00:00 2001 From: huaqingsimeng Date: Wed, 13 Dec 2023 15:38:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E6=81=A2=E5=A4=8D=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E7=BB=93=E6=9D=9F=E5=90=8E=EF=BC=8C=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E6=B8=85=E7=90=86=E8=B5=84=E6=BA=90=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huaqingsimeng --- services/backup_sa/src/module_ipc/service.cpp | 3 +-- .../src/module_ipc/svc_session_manager.cpp | 18 ++++++++++++++++++ utils/include/b_resources/b_constants.h | 11 +++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/services/backup_sa/src/module_ipc/service.cpp b/services/backup_sa/src/module_ipc/service.cpp index aedb23277..df8aaec1b 100644 --- a/services/backup_sa/src/module_ipc/service.cpp +++ b/services/backup_sa/src/module_ipc/service.cpp @@ -613,8 +613,7 @@ void Service::ExtStart(const string &bundleName) if (!proxy) { throw BError(BError::Codes::SA_INVAL_ARG, "Extension backup Proxy is empty"); } - if (session_->GetBundleVersionCode(bundleName) != BConstants::DEFAULT_VERSION_CODE && - session_->GetBundleVersionName(bundleName) != BConstants::DEFAULT_VERSION_NAME && + if (session_->GetBundleVersionName(bundleName) != BConstants::DEFAULT_VERSION_NAME && session_->GetBundleRestoreType(bundleName) != RestoreTypeEnum::RESTORE_DATA_READDY) { proxy->HandleClear(); } diff --git a/services/backup_sa/src/module_ipc/svc_session_manager.cpp b/services/backup_sa/src/module_ipc/svc_session_manager.cpp index f6b89f44a..be5022bb6 100644 --- a/services/backup_sa/src/module_ipc/svc_session_manager.cpp +++ b/services/backup_sa/src/module_ipc/svc_session_manager.cpp @@ -22,6 +22,8 @@ #include #include +#include + #include "b_error/b_error.h" #include "b_file_info.h" #include "b_json/b_json_entity_caps.h" @@ -188,6 +190,20 @@ UniqueFd SvcSessionManager::OnBunleExtManageInfo(const string &bundleName, Uniqu return move(cachedEntity.GetFd()); } +static void RemoveDir(IServiceReverse::Scenario scenario, int32_t userId, const string &bundleName) +{ + // delete extention data + string path = BConstants::GetBundleBackupDir(userId, bundleName); + if (scenario == IServiceReverse::Scenario::BACKUP) { + path.append(BConstants::SA_BUNDLE_BACKUP_BACKUP); + } else { + path.append(BConstants::SA_BUNDLE_BACKUP_RESTORE); + } + if (ForceRemoveDirectory(path)) { + HILOGE("Failed to remove %{public}s: %{public}s", path.c_str(), strerror(errno)); + } +} + void SvcSessionManager::RemoveExtInfo(const string &bundleName) { HILOGI("Begin"); @@ -196,6 +212,8 @@ void SvcSessionManager::RemoveExtInfo(const string &bundleName) if (it == impl_.backupExtNameMap.end()) { return; } + // delete extention data + RemoveDir(impl_.scenario, impl_.userId, bundleName); impl_.backupExtNameMap.erase(it); if (extConnectNum_) { extConnectNum_--; diff --git a/utils/include/b_resources/b_constants.h b/utils/include/b_resources/b_constants.h index 8d486942e..4d24071a7 100644 --- a/utils/include/b_resources/b_constants.h +++ b/utils/include/b_resources/b_constants.h @@ -108,6 +108,17 @@ static inline std::string GetSaBundleBackupToolDir(int32_t userId) return str; } +// 多用户场景应用备份恢复临时数据路径 +static inline std::string GetBundleBackupDir(int32_t userId, std::string bundleName) +{ + std::string str; + str.append("/data/service/el2/"); + str.append(std::to_string(userId)); + str.append("/backup/bundles/"); + str.append(bundleName); + return str; +} + // 备份恢复配置文件暂存路径 static inline std::string_view BACKUP_CONFIG_EXTENSION_PATH = "/data/storage/el2/base/temp/"; -- Gitee