diff --git a/services/bundlemgr/src/installd/installd_host_impl.cpp b/services/bundlemgr/src/installd/installd_host_impl.cpp index d646747a68fde21aed69c567d05774690720d833..5039de809487942557108a60b70a8e19eb26e767 100644 --- a/services/bundlemgr/src/installd/installd_host_impl.cpp +++ b/services/bundlemgr/src/installd/installd_host_impl.cpp @@ -1320,7 +1320,7 @@ int64_t InstalldHostImpl::GetEl2CacheSize(const int32_t projectId, const std::st std::string cachePath = std::string(ServiceConstants::BUNDLE_APP_DATA_BASE_DIR) + ServiceConstants::DIR_EL2 + ServiceConstants::PATH_SEPARATOR + std::to_string(userId) + ServiceConstants::BASE + bundleNameDir + ServiceConstants::PATH_SEPARATOR + Constants::CACHE_DIR; - if (InstalldOperator::IsDirEmptyFast(cachePath)) { + if (!InstalldOperator::IsExistDir(cachePath) || InstalldOperator::IsDirEmptyFast(cachePath)) { LOG_I(BMS_TAG_INSTALLD, "%{public}s el2 cache dir empty", bundleNameDir.c_str()); return 0; } diff --git a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_host_impl_test.cpp b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_host_impl_test.cpp index 5249220a6a1d2921f0977e4a8043f42c601d2f23..b9eba6875dac6203e11fb83903d478183c0d45e4 100755 --- a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_host_impl_test.cpp +++ b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_host_impl_test.cpp @@ -1390,6 +1390,7 @@ HWTEST_F(BmsInstallDaemonHostImplTest, InstalldHostImplTest_8000, Function | Sma auto hostImpl = GetInstalldHostImpl(); ASSERT_NE(hostImpl, nullptr); EXPECT_TRUE(InstalldOperator::DeleteDir("/data/app/el2/100/base/com.test.8000")); + EXPECT_EQ(hostImpl->GetEl2CacheSize(8000, "com.test.8000", 100, 0), 0); EXPECT_TRUE(InstalldOperator::MkRecursiveDir("/data/app/el2/100/base/com.test.8000/cache", true)); EXPECT_EQ(hostImpl->GetEl2CacheSize(8000, "com.test.8000", 100, 0), 0); diff --git a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_test.cpp b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_test.cpp index 18e58b4fb7780432e4be2f3f3347ec6444d405bd..20edabf71de8e7ca1d7b7e47af4bf91bce4a82cb 100644 --- a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_test.cpp +++ b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_test.cpp @@ -947,7 +947,7 @@ HWTEST_F(BmsInstallDaemonTest, GetBundleStats_0200, Function | SmallTest | Level EXPECT_NE(stats[1], 0); EXPECT_EQ(stats[2], 0); EXPECT_EQ(stats[3], 0); - EXPECT_NE(stats[4], 0); + EXPECT_EQ(stats[4], 0); } /**