diff --git a/services/bundlemgr/src/installd/installd_host_impl.cpp b/services/bundlemgr/src/installd/installd_host_impl.cpp index d97f2ef858d60b592ff352c94f81a1e2d0ed77f8..4c4dc2f91751bd4fe3a85a3bb1ef93e36fa08e85 100644 --- a/services/bundlemgr/src/installd/installd_host_impl.cpp +++ b/services/bundlemgr/src/installd/installd_host_impl.cpp @@ -1332,7 +1332,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 3410f8583605081feb0deee184b18f876bb932a7..7747a8b040e2cadac6d8fe4c1327ffc97b81750a 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 @@ -1389,6 +1389,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); } /**