diff --git a/frameworks/native/backup_kit_inner/src/b_session_restore_async.cpp b/frameworks/native/backup_kit_inner/src/b_session_restore_async.cpp index 38e8e167320abe27fd87e18e4b4bdd8c85fa5928..c3f0b8ee83e61332d088d87a8e4457d31f08e5f2 100644 --- a/frameworks/native/backup_kit_inner/src/b_session_restore_async.cpp +++ b/frameworks/native/backup_kit_inner/src/b_session_restore_async.cpp @@ -139,7 +139,8 @@ void BSessionRestoreAsync::AppendBundlesImpl(AppendBundleInfo info) { auto proxy = ServiceProxy::GetInstance(); if (proxy == nullptr) { - BError(BError::Codes::SDK_BROKEN_IPC, "Failed to get backup service").GetCode(); + return OnBundleStarted(BError(BError::Codes::SDK_BROKEN_IPC, "Failed to get backup service").GetCode(), + info.bundlesToRestore); } auto onBackupServiceDied = bind(&BSessionRestoreAsync::OnBackupServiceDied, shared_from_this()); RegisterBackupServiceDied(onBackupServiceDied); diff --git a/tools/backup_tool/BUILD.gn b/tools/backup_tool/BUILD.gn index f27c0d80ef2db3d426ba3dd3078a116d6292a9e3..6d8c5f5ed9c33d841576f3a68d563531d992eef9 100644 --- a/tools/backup_tool/BUILD.gn +++ b/tools/backup_tool/BUILD.gn @@ -22,6 +22,7 @@ ohos_executable("backup_tool") { "src/tools_op_check_sa.cpp", "src/tools_op_help.cpp", "src/tools_op_restore.cpp", + "src/tools_op_restore_async.cpp", ] defines = [ diff --git a/tools/backup_tool/src/tools_op_restore_async.cpp b/tools/backup_tool/src/tools_op_restore_async.cpp index b79f15d2ae0b1e250966ed5755c5655686e374a6..82ed497795d434e044fe08ea40b240de34e2343f 100644 --- a/tools/backup_tool/src/tools_op_restore_async.cpp +++ b/tools/backup_tool/src/tools_op_restore_async.cpp @@ -239,7 +239,10 @@ static int32_t AppendBundles(shared_ptr restore, return 0; } -static int32_t InitArg(const string &pathCapFile, vector bundleNames, const string &type, const string &userId) +static int32_t InitArg(const string &pathCapFile, + const vector &bundleNames, + const string &type, + const string &userId) { StartTrace(HITRACE_TAG_FILEMANAGEMENT, "Init"); BExcepUltils::VerifyPath(pathCapFile, false); @@ -268,7 +271,7 @@ static int32_t InitArg(const string &pathCapFile, vector bundleNames, co static int Exec(map> &mapArgToVal) { if (mapArgToVal.find("pathCapFile") == mapArgToVal.end() || mapArgToVal.find("bundles") == mapArgToVal.end() || - mapArgToVal["restoreType"].empty() || mapArgToVal["userId"].empty()) { + mapArgToVal.find("restoreType") == mapArgToVal.end() || mapArgToVal.find("userId") == mapArgToVal.end()) { return -EPERM; } return InitArg(*(mapArgToVal["pathCapFile"].begin()), mapArgToVal["bundles"], *(mapArgToVal["restoreType"].begin()),