From 92c4459869cdbbd4c524ec72a20164e44ea947d8 Mon Sep 17 00:00:00 2001 From: fengyang Date: Tue, 13 May 2025 09:38:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A9=BA=E6=8C=87=E9=92=88?= =?UTF-8?q?=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fengyang --- services/common/src/bundle_active_usage_database.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/services/common/src/bundle_active_usage_database.cpp b/services/common/src/bundle_active_usage_database.cpp index 4b611a6..0104f5c 100644 --- a/services/common/src/bundle_active_usage_database.cpp +++ b/services/common/src/bundle_active_usage_database.cpp @@ -990,15 +990,16 @@ pair BundleActiveUsageDatabase::GetDurationData() void BundleActiveUsageDatabase::FlushPackageInfo(uint32_t databaseType, const BundleActivePeriodStats &stats) { shared_ptr rdbStore = GetBundleActiveRdbStore(databaseType); - if (rdbStore == nullptr) { - BUNDLE_ACTIVE_LOGE("flush package info fail, rdbStore is nullptr"); + if (rdbStore == nullptr || stats.bundleStats_.empty()) { + BUNDLE_ACTIVE_LOGE("flush package info fail, rdbStore is nullptr or bundleStats is empty"); return; } string tableName = PACKAGE_LOG_TABLE + to_string(stats.beginTime_); int32_t changeRow = BUNDLE_ACTIVE_FAIL; std::vector valuesBuckets; vector queryCondition; - for (auto iter = stats.bundleStats_.begin(); iter != stats.bundleStats_.end(); iter++) { + auto bundleStats = stats.bundleStats_; + for (auto iter = bundleStats.begin(); iter != bundleStats.end(); iter++) { if (iter->second == nullptr || (iter->second->totalInFrontTime_ == 0 && iter->second->totalContiniousTaskUsedTime_ == 0)) { continue; -- Gitee