diff --git a/services/backup_sa/src/module_ipc/service.cpp b/services/backup_sa/src/module_ipc/service.cpp index aedb2327731880814acbf5c613165db68b51d23b..df8aaec1b99270f53fba88c7c7c3027764bd6afe 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 f6b89f44a216bfa7d1a0c339182d276cb18db985..be5022bb6006865adf4887268a2279f9fce97563 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 8d486942eb3b5e313e84143dae631a5ca3d01422..4d24071a79fd0a958b9a9ce794557ce2717bfd96 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/";