From bbdbe0f42123f277ca3e61ded12aa7c45a2fa306 Mon Sep 17 00:00:00 2001 From: zhuruigan Date: Sun, 4 Feb 2024 11:41:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E9=87=8F=E5=A4=87=E4=BB=BD=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=88=86=E6=9E=90=E8=BF=94=E5=9B=9E=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhuruigan Change-Id: Ifb93455635b84b8073fd3dbfaeff89ebdec49dc9 --- frameworks/native/backup_ext/include/untar_file.h | 4 ++-- frameworks/native/backup_ext/src/ext_extension.cpp | 7 ++++--- frameworks/native/backup_ext/src/tar_file.cpp | 4 +++- frameworks/native/backup_ext/src/untar_file.cpp | 2 +- .../unittests/backup_utils/b_json/b_report_entity_test.cpp | 2 +- utils/include/b_json/b_report_entity.h | 2 +- utils/src/b_json/b_report_entity.cpp | 6 +++--- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/frameworks/native/backup_ext/include/untar_file.h b/frameworks/native/backup_ext/include/untar_file.h index 6bd0e4200..c2a28dc2d 100644 --- a/frameworks/native/backup_ext/include/untar_file.h +++ b/frameworks/native/backup_ext/include/untar_file.h @@ -34,7 +34,7 @@ public: static UntarFile &GetInstance(); int UnPacket(const std::string &tarFile, const std::string &rootPath); int IncrementalUnPacket(const std::string &tarFile, const std::string &rootPath, - const std::map &includes); + const std::unordered_map &includes); private: UntarFile() = default; @@ -147,7 +147,7 @@ private: off_t tarFileBlockCnt_ {0}; off_t pos_ {0}; size_t readCnt_ {0}; - std::map includes_; + std::unordered_map includes_; }; } // namespace OHOS::FileManagement::Backup diff --git a/frameworks/native/backup_ext/src/ext_extension.cpp b/frameworks/native/backup_ext/src/ext_extension.cpp index 3c29b896c..bf1da1454 100644 --- a/frameworks/native/backup_ext/src/ext_extension.cpp +++ b/frameworks/native/backup_ext/src/ext_extension.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -543,7 +544,7 @@ int BackupExtExtension::DoRestore(const string &fileName) return ERR_OK; } -static map GetTarIncludes(const string &tarName) +static unordered_map GetTarIncludes(const string &tarName) { // 获取简报文件内容 string reportName = GetReportFileName(tarName); @@ -1145,9 +1146,9 @@ using CompareFilesResult = tuple, static CompareFilesResult CompareFiles(const UniqueFd &cloudFd, const UniqueFd &storageFd) { BReportEntity cloudRp(UniqueFd(cloudFd.Get())); - map cloudFiles = cloudRp.GetReportInfos(); + unordered_map cloudFiles = cloudRp.GetReportInfos(); BReportEntity storageRp(UniqueFd(storageFd.Get())); - map storageFiles = storageRp.GetReportInfos(); + unordered_map storageFiles = storageRp.GetReportInfos(); map allFiles; map smallFiles; map bigFiles; diff --git a/frameworks/native/backup_ext/src/tar_file.cpp b/frameworks/native/backup_ext/src/tar_file.cpp index 2b4b0bce3..3a7d9969e 100644 --- a/frameworks/native/backup_ext/src/tar_file.cpp +++ b/frameworks/native/backup_ext/src/tar_file.cpp @@ -114,6 +114,8 @@ bool TarFile::TraversalFile(string &filePath) } if (currentTarFileSize_ >= DEFAULT_SLICE_SIZE) { + HILOGI("Current tar file size is over %{public}d, start to slice", + static_cast(DEFAULT_SLICE_SIZE / MB_TO_BYTE)); fileCount_ = 0; FillSplitTailBlocks(); CreateSplitTarFile(); @@ -307,7 +309,7 @@ bool TarFile::FillSplitTailBlocks() if (currentTarFile_ == nullptr) { throw BError(BError::Codes::EXT_BACKUP_PACKET_ERROR, "FillSplitTailBlocks currentTarFile_ is null"); } - + // write tar file tail const int END_BLOCK_SIZE = 1024; vector buff {}; diff --git a/frameworks/native/backup_ext/src/untar_file.cpp b/frameworks/native/backup_ext/src/untar_file.cpp index ebff9a541..1beb90bb9 100644 --- a/frameworks/native/backup_ext/src/untar_file.cpp +++ b/frameworks/native/backup_ext/src/untar_file.cpp @@ -95,7 +95,7 @@ int UntarFile::UnPacket(const string &tarFile, const string &rootPath) } int UntarFile::IncrementalUnPacket(const string &tarFile, const string &rootPath, - const map &includes) + const unordered_map &includes) { includes_ = includes; tarFilePtr_ = fopen(tarFile.c_str(), "rb"); diff --git a/tests/unittests/backup_utils/b_json/b_report_entity_test.cpp b/tests/unittests/backup_utils/b_json/b_report_entity_test.cpp index a94a6ca95..40a952afc 100644 --- a/tests/unittests/backup_utils/b_json/b_report_entity_test.cpp +++ b/tests/unittests/backup_utils/b_json/b_report_entity_test.cpp @@ -78,7 +78,7 @@ HWTEST_F(BReportEntityTest, b_report_entity_GetReportInfos_0100, testing::ext::T const auto [filePath, res] = GetTestFile(tm, content); BReportEntity cloudRp(UniqueFd(open(filePath.data(), O_RDONLY, 0))); - map cloudFiles = cloudRp.GetReportInfos(); + unordered_map cloudFiles = cloudRp.GetReportInfos(); bool flag = false; diff --git a/utils/include/b_json/b_report_entity.h b/utils/include/b_json/b_report_entity.h index 9bdc59df9..38dd8e477 100644 --- a/utils/include/b_json/b_report_entity.h +++ b/utils/include/b_json/b_report_entity.h @@ -41,7 +41,7 @@ public: * * @return std::map */ - std::map GetReportInfos(); + std::unordered_map GetReportInfos(); public: /** diff --git a/utils/src/b_json/b_report_entity.cpp b/utils/src/b_json/b_report_entity.cpp index 816441b6e..5d4ac0826 100644 --- a/utils/src/b_json/b_report_entity.cpp +++ b/utils/src/b_json/b_report_entity.cpp @@ -111,7 +111,7 @@ static ErrCode ParseReportInfo(struct ReportFileInfo &fileStat, static void DealLine(unordered_map &keys, int &num, const string &line, - map &infos) + unordered_map &infos) { string currentLine = line; if (currentLine[currentLine.length() - 1] == LINE_WRAP) { @@ -137,9 +137,9 @@ static void DealLine(unordered_map &keys, } } -map BReportEntity::GetReportInfos() +unordered_map BReportEntity::GetReportInfos() { - map infos {}; + unordered_map infos {}; char buffer[HASH_BUFFER_SIZE]; ssize_t bytesRead; -- Gitee