diff --git a/services/bundlemgr/include/installd/installd_operator.h b/services/bundlemgr/include/installd/installd_operator.h index 92f0d32de..f9d84983a 100644 --- a/services/bundlemgr/include/installd/installd_operator.h +++ b/services/bundlemgr/include/installd/installd_operator.h @@ -330,7 +330,7 @@ private: static EnforceMetadataProcessForApp enforceMetadataProcessForApp_; static bool OpenEncryptionHandle(); #endif - static void FsyncResFile(const std::string &path, const ExtractFileType &extractFileType); + static void FsyncFile(const std::string &path); static std::string GetSameLevelTmpPath(const std::string &path); }; } // namespace AppExecFwk diff --git a/services/bundlemgr/src/base_extractor.cpp b/services/bundlemgr/src/base_extractor.cpp index 66f231b4a..5de271dec 100644 --- a/services/bundlemgr/src/base_extractor.cpp +++ b/services/bundlemgr/src/base_extractor.cpp @@ -104,7 +104,6 @@ bool BaseExtractor::ExtractFile(const std::string &fileName, const std::string & } return false; } - fileStream.flush(); fileStream.clear(); fileStream.close(); return true; diff --git a/services/bundlemgr/src/installd/installd_operator.cpp b/services/bundlemgr/src/installd/installd_operator.cpp index 1fb9635d3..7e4ef79ad 100644 --- a/services/bundlemgr/src/installd/installd_operator.cpp +++ b/services/bundlemgr/src/installd/installd_operator.cpp @@ -617,23 +617,21 @@ void InstalldOperator::ExtractTargetFile(const BundleExtractor &extractor, const LOG_E(BMS_TAG_INSTALLD, "ChangeModeFile %{public}s failed, errno: %{public}d", path.c_str(), errno); return; } - FsyncResFile(path, extractFileType); + FsyncFile(path); LOG_D(BMS_TAG_INSTALLD, "extract file success, path : %{public}s", path.c_str()); } -void InstalldOperator::FsyncResFile(const std::string &path, const ExtractFileType &extractFileType) +void InstalldOperator::FsyncFile(const std::string &path) { - if (extractFileType == ExtractFileType::RES_FILE) { - int32_t fileFd = open(path.c_str(), O_RDONLY); - if (fileFd < 0) { - LOG_E(BMS_TAG_INSTALLER, "open %{public}s failed", path.c_str()); - return; - } - if (fsync(fileFd) != 0) { - LOG_E(BMS_TAG_INSTALLER, "fsync %{public}s failed", path.c_str()); - } - close(fileFd); + int32_t fileFd = open(path.c_str(), O_RDONLY); + if (fileFd < 0) { + LOG_E(BMS_TAG_INSTALLER, "open %{public}s failed %{public}d", path.c_str(), errno); + return; } + if (fsync(fileFd) != 0) { + LOG_E(BMS_TAG_INSTALLER, "fsync %{public}s failed %{public}d", path.c_str(), errno); + } + close(fileFd); } bool InstalldOperator::DeterminePrefix(const ExtractFileType &extractFileType, const std::string &cpuAbi,