From 9523e9543f2c6422f1cc4e35444555eaa36648b3 Mon Sep 17 00:00:00 2001 From: BrainL Date: Tue, 6 Aug 2024 13:22:41 +0800 Subject: [PATCH 1/7] deal with user0 Signed-off-by: BrainL --- .../backup_sa/src/module_external/bms_adapter.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/services/backup_sa/src/module_external/bms_adapter.cpp b/services/backup_sa/src/module_external/bms_adapter.cpp index 87b1cfda4..cb3a2f9a8 100644 --- a/services/backup_sa/src/module_external/bms_adapter.cpp +++ b/services/backup_sa/src/module_external/bms_adapter.cpp @@ -130,7 +130,8 @@ vector BundleMgrAdapter::GetBundleInfos(const vecto throw BError(BError::Codes::SA_BUNDLE_INFO_EMPTY, "Failed to get bundle info"); } if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || - installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { + installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH || + installedBundle.applicationInfo.singleton == true) { HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); continue; } @@ -288,8 +289,9 @@ vector BundleMgrAdapter::GetBundleInfosForIncrement throw BError(BError::Codes::SA_BROKEN_IPC, "Failed to get bundle info"); } if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || - installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { - HILOGI("Unsupported applications, name : %{private}s", installedBundle.name.data()); + installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH || + installedBundle.applicationInfo.singleton == true) { + HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); continue; } struct BJsonEntityCaps::BundleBackupConfigPara backupPara; @@ -335,7 +337,8 @@ vector BundleMgrAdapter::GetBundleInfosForIncrement HILOGI("Begin get bundle infos"); for (auto const &installedBundle : installedBundles) { if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || - installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { + installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH || + installedBundle.applicationInfo.singleton == true) { HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); continue; } @@ -374,7 +377,8 @@ string BundleMgrAdapter::GetExtName(string bundleName, int32_t userId) } for (auto const &installedBundle : installedBundles) { if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || - installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { + installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH || + installedBundle.applicationInfo.singleton == true) { HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); continue; } -- Gitee From cca25d25f116374ebe25708795015a54cc5eb16d Mon Sep 17 00:00:00 2001 From: BrainL Date: Tue, 6 Aug 2024 11:26:10 +0000 Subject: [PATCH 2/7] update services/backup_sa/src/module_ipc/service.cpp. Signed-off-by: BrainL --- services/backup_sa/src/module_ipc/service.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/services/backup_sa/src/module_ipc/service.cpp b/services/backup_sa/src/module_ipc/service.cpp index cd8b32020..814e16d8d 100644 --- a/services/backup_sa/src/module_ipc/service.cpp +++ b/services/backup_sa/src/module_ipc/service.cpp @@ -311,9 +311,22 @@ static void OnBundleStarted(BError error, sptr session, const session->GetServiceReverseProxy()->IncrementalRestoreOnBundleStarted(error, bundleName); } else if (scenario == IServiceReverse::Scenario::RESTORE) { session->GetServiceReverseProxy()->RestoreOnBundleStarted(error, bundleName); + } else if (scenario == IServiceReverse::Scenario::BACKUP && session->GetIsIncrementalBackup()) { + session->GetServiceReverseProxy()->IncrementalBackupOnBundleStarted(error, bundleName); + } else if (scenario == IServiceReverse::Scenario::BACKUP) { + session->GetServiceReverseProxy()->BackupOnBundleStarted(error, bundleName); } } +static vector GetBackupBundleNames(const vector &bundleInfos) +{ + vector backupBundleNames {}; + for (auto &bundleInfo : bundleInfos) { + backupBundleNames.emplace_back(bundleInfo.name); + } + return backupBundleNames; +} + static vector GetRestoreBundleNames(UniqueFd fd, sptr session, const vector &bundleNames) @@ -535,7 +548,9 @@ ErrCode Service::AppendBundlesBackupSession(const vector &bundleName session_->IncreaseSessionCnt(); // BundleMgrAdapter::GetBundleInfos可能耗时 VerifyCaller(IServiceReverse::Scenario::BACKUP); auto backupInfos = BundleMgrAdapter::GetBundleInfos(bundleNames, session_->GetSessionUserId()); - session_->AppendBundles(bundleNames); + auto backupBundles = GetBackupBundleNames(backupInfos); + HandleExceptionOnAppendBundles(session_, bundleNames, backupBundles); + session_->AppendBundles(backupBundles); for (auto info : backupInfos) { session_->SetBundleDataSize(info.name, info.spaceOccupied); session_->SetBackupExtName(info.name, info.extensionName); @@ -577,7 +592,9 @@ ErrCode Service::AppendBundlesDetailsBackupSession(const vector &bun std::map> bundleNameDetailMap = BJsonUtil::BuildBundleInfos(bundleNames, bundleInfos, bundleNamesOnly, session_->GetSessionUserId()); auto backupInfos = BundleMgrAdapter::GetBundleInfos(bundleNames, session_->GetSessionUserId()); - session_->AppendBundles(bundleNames); + auto backupBundles = GetBackupBundleNames(backupInfos); + HandleExceptionOnAppendBundles(session_, bundleNames, backupBundles); + session_->AppendBundles(backupBundles); for (auto info : backupInfos) { session_->SetBundleDataSize(info.name, info.spaceOccupied); session_->SetBackupExtName(info.name, info.extensionName); -- Gitee From b7df65389e2e9efd04412ee8d1ba8838c515fd28 Mon Sep 17 00:00:00 2001 From: BrainL Date: Tue, 6 Aug 2024 12:06:19 +0000 Subject: [PATCH 3/7] update services/backup_sa/src/module_external/bms_adapter.cpp. Signed-off-by: BrainL --- services/backup_sa/src/module_external/bms_adapter.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/services/backup_sa/src/module_external/bms_adapter.cpp b/services/backup_sa/src/module_external/bms_adapter.cpp index cb3a2f9a8..14c4cc434 100644 --- a/services/backup_sa/src/module_external/bms_adapter.cpp +++ b/services/backup_sa/src/module_external/bms_adapter.cpp @@ -289,8 +289,7 @@ vector BundleMgrAdapter::GetBundleInfosForIncrement throw BError(BError::Codes::SA_BROKEN_IPC, "Failed to get bundle info"); } if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || - installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH || - installedBundle.applicationInfo.singleton == true) { + installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); continue; } @@ -337,8 +336,7 @@ vector BundleMgrAdapter::GetBundleInfosForIncrement HILOGI("Begin get bundle infos"); for (auto const &installedBundle : installedBundles) { if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || - installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH || - installedBundle.applicationInfo.singleton == true) { + installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); continue; } @@ -377,8 +375,7 @@ string BundleMgrAdapter::GetExtName(string bundleName, int32_t userId) } for (auto const &installedBundle : installedBundles) { if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || - installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH || - installedBundle.applicationInfo.singleton == true) { + installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); continue; } -- Gitee From 220470ef5b891c8a5b6ba460f098b023bbe138ae Mon Sep 17 00:00:00 2001 From: BrainL Date: Tue, 6 Aug 2024 12:27:08 +0000 Subject: [PATCH 4/7] update services/backup_sa/src/module_external/bms_adapter.cpp. Signed-off-by: BrainL --- services/backup_sa/src/module_external/bms_adapter.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/backup_sa/src/module_external/bms_adapter.cpp b/services/backup_sa/src/module_external/bms_adapter.cpp index 14c4cc434..cb3a2f9a8 100644 --- a/services/backup_sa/src/module_external/bms_adapter.cpp +++ b/services/backup_sa/src/module_external/bms_adapter.cpp @@ -289,7 +289,8 @@ vector BundleMgrAdapter::GetBundleInfosForIncrement throw BError(BError::Codes::SA_BROKEN_IPC, "Failed to get bundle info"); } if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || - installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { + installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH || + installedBundle.applicationInfo.singleton == true) { HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); continue; } @@ -336,7 +337,8 @@ vector BundleMgrAdapter::GetBundleInfosForIncrement HILOGI("Begin get bundle infos"); for (auto const &installedBundle : installedBundles) { if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || - installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { + installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH || + installedBundle.applicationInfo.singleton == true) { HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); continue; } @@ -375,7 +377,8 @@ string BundleMgrAdapter::GetExtName(string bundleName, int32_t userId) } for (auto const &installedBundle : installedBundles) { if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || - installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { + installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH || + installedBundle.applicationInfo.singleton == true) { HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); continue; } -- Gitee From a455b643762acbb525b35c159157d295ad050884 Mon Sep 17 00:00:00 2001 From: BrainL Date: Wed, 7 Aug 2024 07:58:43 +0000 Subject: [PATCH 5/7] update services/backup_sa/src/module_external/bms_adapter.cpp. Signed-off-by: BrainL --- services/backup_sa/src/module_external/bms_adapter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/backup_sa/src/module_external/bms_adapter.cpp b/services/backup_sa/src/module_external/bms_adapter.cpp index cb3a2f9a8..0b2fd0d2a 100644 --- a/services/backup_sa/src/module_external/bms_adapter.cpp +++ b/services/backup_sa/src/module_external/bms_adapter.cpp @@ -377,8 +377,7 @@ string BundleMgrAdapter::GetExtName(string bundleName, int32_t userId) } for (auto const &installedBundle : installedBundles) { if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || - installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH || - installedBundle.applicationInfo.singleton == true) { + installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); continue; } -- Gitee From 7b530300ac2b2bb26ee83a992a08f79f5163e960 Mon Sep 17 00:00:00 2001 From: BrainL Date: Sun, 11 Aug 2024 08:55:04 +0000 Subject: [PATCH 6/7] update services/backup_sa/src/module_external/bms_adapter.cpp. Signed-off-by: BrainL --- .../src/module_external/bms_adapter.cpp | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/services/backup_sa/src/module_external/bms_adapter.cpp b/services/backup_sa/src/module_external/bms_adapter.cpp index e865a4962..7a3465562 100644 --- a/services/backup_sa/src/module_external/bms_adapter.cpp +++ b/services/backup_sa/src/module_external/bms_adapter.cpp @@ -123,19 +123,6 @@ vector BundleMgrAdapter::GetBundleInfos(const vecto continue; } AppExecFwk::BundleInfo installedBundle; - if (!bms->GetBundleInfo(bundleName, AppExecFwk::GET_BUNDLE_WITH_EXTENSION_INFO, installedBundle, userId)) { - if (bundleNames.size() != SINGLE_BUNDLE_NUM) { - HILOGE("bundleName:%{public}s, current bundle info for backup/restore is empty", bundleName.c_str()); - continue; - } - throw BError(BError::Codes::SA_BUNDLE_INFO_EMPTY, "Failed to get bundle info"); - } - if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || - installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH || - installedBundle.applicationInfo.singleton == true) { - HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); - continue; - } std::vector extensionInfos; bool getBundleSuccess = GetCurBundleExtenionInfo(installedBundle, bundleName, extensionInfos, bms, userId); if (!getBundleSuccess) { @@ -294,15 +281,6 @@ vector BundleMgrAdapter::GetBundleInfosForIncrement auto bundleName = bundleNameTime.bundleName; HILOGD("Begin get bundleName:%{private}s", bundleName.c_str()); AppExecFwk::BundleInfo installedBundle; - if (!bms->GetBundleInfo(bundleName, AppExecFwk::GET_BUNDLE_WITH_EXTENSION_INFO, installedBundle, userId)) { - throw BError(BError::Codes::SA_BROKEN_IPC, "Failed to get bundle info"); - } - if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || - installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH || - installedBundle.applicationInfo.singleton == true) { - HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); - continue; - } std::vector extensionInfos; bool getBundleSuccess = GetCurBundleExtenionInfo(installedBundle, bundleName, extensionInfos, bms, userId); if (!getBundleSuccess) { @@ -474,7 +452,8 @@ bool BundleMgrAdapter::GetCurBundleExtenionInfo(AppExecFwk::BundleInfo &installe return false; } if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || - installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { + installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH || + installedBundle.applicationInfo.singleton == true) { HILOGE("Unsupported applications, name : %{public}s", installedBundle.name.data()); return false; } -- Gitee From 0aebe75847c522c5a86ec4b10cefa1c2fd1e5dd8 Mon Sep 17 00:00:00 2001 From: BrainL Date: Sun, 11 Aug 2024 09:07:10 +0000 Subject: [PATCH 7/7] update services/backup_sa/src/module_ipc/service_incremental.cpp. Signed-off-by: BrainL --- .../src/module_ipc/service_incremental.cpp | 138 ++++++++++++------ 1 file changed, 93 insertions(+), 45 deletions(-) diff --git a/services/backup_sa/src/module_ipc/service_incremental.cpp b/services/backup_sa/src/module_ipc/service_incremental.cpp index 07c6f6f87..5fbd939d6 100644 --- a/services/backup_sa/src/module_ipc/service_incremental.cpp +++ b/services/backup_sa/src/module_ipc/service_incremental.cpp @@ -239,6 +239,77 @@ ErrCode Service::InitIncrementalBackupSession(sptr remote) } } + +static vector GetBackupBundleNames(const vector &bundleInfos) +{ + vector backupBundleNames {}; + for (auto &bundleInfo : bundleInfos) { + backupBundleNames.emplace_back(bundleInfo.name); + } + return backupBundleNames; +} + +static vector GetBackupBundleNameWithIncData(const std::vector &bundlesToBackup) +{ + vector bundleNames {}; + for (auto &bundle : bundlesToBackup) { + bundleNames.emplace_back(bundle.bundleName); + } + return bundleNames; +} + +static void HandleExceptionOnAppendBundles(sptr session, + const vector &appendBundleNames, const vector &curBundleNames) +{ + if (appendBundleNames.size() != curBundleNames.size()) { + HILOGE("AppendBundleNames not equal curBundleNames."); + for (auto bundleName : appendBundleNames) { + auto it = find_if(curBundleNames.begin(), curBundleNames.end(), + [&bundleName](const auto &obj) { return obj == bundleName; }); + if (it == curBundleNames.end()) { + HILOGE("AppendBundles failed, bundleName = %{public}s.", bundleName.c_str()); + session->GetServiceReverseProxy()->IncrementalBackupOnBundleStarted( + BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), bundleName); + } + } + } +} + +static void SetBundleDataForExt(sptr session, + const std::vector &bundlesToBackup, + std::map> bundleNameDetailMap, + vector bundleInfos, bool needUniCast) +{ + for (auto info : bundleInfos) { + session->SetBundleDataSize(info.name, info.spaceOccupied); + session->SetBackupExtName(info.name, info.extensionName); + if (info.allToBackup == false) { + session->GetServiceReverseProxy()->IncrementalBackupOnBundleStarted( + BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), info.name); + session->RemoveExtInfo(info.name); + } + if (needUniCast) { + BJsonUtil::BundleDetailInfo uniCastInfo; + bool uniCastRet = BJsonUtil::FindBundleInfoByName(bundleNameDetailMap, info.name, UNICAST_TYPE, + uniCastInfo); + if (uniCastRet) { + HILOGI("Current bundle, unicast info:%{public}s", GetAnonyString(uniCastInfo.detail).c_str()); + session->SetBackupExtInfo(info.name, uniCastInfo.detail); + } + } + } + for (auto &bundleInfo : bundlesToBackup) { + auto it = find_if(bundleInfos.begin(), bundleInfos.end(), + [&bundleInfo](const auto &obj) { return obj.name == bundleInfo.bundleName; }); + if (it == bundleInfos.end()) { + HILOGI("Bundle does not need to be setIncrementalData, bundleName = %{public}s.", + bundleInfo.bundleName.c_str()); + continue; + } + session->SetIncrementalData(bundleInfo); + } +} + ErrCode Service::AppendBundlesIncrementalBackupSession(const std::vector &bundlesToBackup) { HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); @@ -249,34 +320,26 @@ ErrCode Service::AppendBundlesIncrementalBackupSession(const std::vectorIncreaseSessionCnt(); // BundleMgrAdapter::GetBundleInfos可能耗时 VerifyCaller(IServiceReverse::Scenario::BACKUP); - vector bundleNames {}; - for (auto &bundle : bundlesToBackup) { - bundleNames.emplace_back(bundle.bundleName); - } + auto bundleNames = GetBackupBundleNameWithIncData(bundlesToBackup); auto backupInfos = BundleMgrAdapter::GetBundleInfos(bundleNames, session_->GetSessionUserId()); - session_->AppendBundles(bundleNames); - for (auto info : backupInfos) { - session_->SetBundleDataSize(info.name, info.spaceOccupied); - session_->SetBackupExtName(info.name, info.extensionName); - if (info.allToBackup == false) { - session_->GetServiceReverseProxy()->IncrementalBackupOnBundleStarted( - BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), info.name); - session_->RemoveExtInfo(info.name); - } - } - for (auto &bundleInfo : bundlesToBackup) { - session_->SetIncrementalData(bundleInfo); - } + auto backupBundles = GetBackupBundleNames(backupInfos); + HandleExceptionOnAppendBundles(session_, bundleNames, backupBundles); + session_->AppendBundles(backupBundles); + SetBundleDataForExt(session_, bundlesToBackup, {}, backupInfos, false); OnStartSched(); session_->DecreaseSessionCnt(); return BError(BError::Codes::OK); } catch (const BError &e) { - session_->DecreaseSessionCnt(); HILOGE("Failed, errCode = %{public}d", e.GetCode()); + auto bundleNames = GetBackupBundleNameWithIncData(bundlesToBackup); + HandleExceptionOnAppendBundles(session_, bundleNames, {}); + session_->DecreaseSessionCnt(); return e.GetCode(); } catch (...) { - session_->DecreaseSessionCnt(); HILOGI("Unexpected exception"); + auto bundleNames = GetBackupBundleNameWithIncData(bundlesToBackup); + HandleExceptionOnAppendBundles(session_, bundleNames, {}); + session_->DecreaseSessionCnt(); return EPERM; } } @@ -288,44 +351,29 @@ ErrCode Service::AppendBundlesIncrementalBackupSession(const std::vectorIncreaseSessionCnt(); // BundleMgrAdapter::GetBundleInfos可能耗时 VerifyCaller(IServiceReverse::Scenario::BACKUP); - vector bundleNames {}; - for (auto &bundle : bundlesToBackup) { - bundleNames.emplace_back(bundle.bundleName); - } + auto bundleNames = GetBackupBundleNameWithIncData(bundlesToBackup); std::vector bundleNamesOnly; std::map> bundleNameDetailMap = BJsonUtil::BuildBundleInfos(bundleNames, infos, bundleNamesOnly, session_->GetSessionUserId()); auto backupInfos = BundleMgrAdapter::GetBundleInfos(bundleNames, session_->GetSessionUserId()); - session_->AppendBundles(bundleNames); - for (auto info : backupInfos) { - session_->SetBundleDataSize(info.name, info.spaceOccupied); - session_->SetBackupExtName(info.name, info.extensionName); - if (info.allToBackup == false) { - session_->GetServiceReverseProxy()->IncrementalBackupOnBundleStarted( - BError(BError::Codes::SA_FORBID_BACKUP_RESTORE), info.name); - session_->RemoveExtInfo(info.name); - } - BJsonUtil::BundleDetailInfo uniCastInfo; - bool uniCastRet = BJsonUtil::FindBundleInfoByName(bundleNameDetailMap, info.name, UNICAST_TYPE, - uniCastInfo); - if (uniCastRet) { - HILOGI("current bundle, unicast info:%{public}s", GetAnonyString(uniCastInfo.detail).c_str()); - session_->SetBackupExtInfo(info.name, uniCastInfo.detail); - } - } - for (auto &bundleInfo : bundlesToBackup) { - session_->SetIncrementalData(bundleInfo); - } + auto backupBundles = GetBackupBundleNames(backupInfos); + HandleExceptionOnAppendBundles(session_, bundleNames, backupBundles); + session_->AppendBundles(backupBundles); + SetBundleDataForExt(session_, bundlesToBackup, bundleNameDetailMap, backupInfos, true); OnStartSched(); session_->DecreaseSessionCnt(); return BError(BError::Codes::OK); } catch (const BError &e) { - session_->DecreaseSessionCnt(); HILOGE("Failed, errCode = %{public}d", e.GetCode()); + auto bundleNames = GetBackupBundleNameWithIncData(bundlesToBackup); + HandleExceptionOnAppendBundles(session_, bundleNames, {}); + session_->DecreaseSessionCnt(); return e.GetCode(); } catch (...) { - session_->DecreaseSessionCnt(); HILOGI("Unexpected exception"); + auto bundleNames = GetBackupBundleNameWithIncData(bundlesToBackup); + HandleExceptionOnAppendBundles(session_, bundleNames, {}); + session_->DecreaseSessionCnt(); return EPERM; } } -- Gitee