IssueNo: #I5261G:fix clean cache bug

Description:fix clean cache bug
Sig:SIG_ApplicaitonFramework
Feature or Bugfix:BugFix
Binary Source:No
Signed-off-by: wangtiantian <wangtiantian19@huawei.com>
This commit is contained in:
wangtiantian 2022-04-12 14:18:31 +08:00
parent a8b012dd37
commit 1cc54126bc
5 changed files with 7 additions and 9 deletions

View File

@ -118,7 +118,7 @@ public:
* @brief Get all cache file path.
* @param dir Indicates the data dir.
* @param cachesPath Indicates the cache file path.
* @return Returns ERR_OK if get cache file path successfully; returns error code otherwise.
* @return Returns ERR_OK if get cache file path successfully; returns error code otherwise.
*/
ErrCode GetBundleCachePath(const std::string &dir, std::vector<std::string> &cachePath);

View File

@ -109,7 +109,7 @@ public:
* @brief Get all cache file path.
* @param dir Indicates the data dir.
* @param cachesPath Indicates the cache file path.
* @return Returns ERR_OK if set apl successfully; returns error code otherwise.
* @return Returns ERR_OK if get cache file path successfully; returns error code otherwise.
*/
virtual ErrCode GetBundleCachePath(const std::string &dir, std::vector<std::string> &cachePath) = 0;
protected:

View File

@ -109,7 +109,7 @@ public:
* @brief Get all cache file path.
* @param dir Indicates the data dir.
* @param cachesPath Indicates the cache file path.
* @return Returns ERR_OK if set apl successfully; returns error code otherwise.
* @return Returns ERR_OK if get cache file path successfully; returns error code otherwise.
*/
virtual ErrCode GetBundleCachePath(const std::string &dir, std::vector<std::string> &cachePath) override;

View File

@ -532,19 +532,17 @@ void BundleMgrHostImpl::CleanBundleCacheTask(const std::string &bundleName,
}
auto cleanCache = [rootDir, cleanCacheCallback]() {
std::vector<std::string> caches;
bool result = false;
for (const auto &st : rootDir) {
std::vector<std::string> cache;
result = InstalldClient::GetInstance()->GetBundleCachePath(st, cache);
if (result) {
break;
if (InstalldClient::GetInstance()->GetBundleCachePath(st, cache) != ERR_OK) {
APP_LOGE("GetBundleCachePath failed, path: %{public}s", st.c_str());
}
for (const auto &item : cache) {
caches.emplace_back(item);
}
}
bool error = false;
if (result) {
if (!caches.empty()) {
for (const auto& cache : caches) {
error = InstalldClient::GetInstance()->CleanBundleDataDir(cache);
if (error) {

View File

@ -127,7 +127,7 @@ ErrCode InstalldClient::SetDirApl(const std::string &dir, const std::string &bun
return CallService(&IInstalld::SetDirApl, dir, bundleName, apl);
}
ErrCode GetBundleCachePath(const std::string &dir, std::vector<std::string> &cachePath)
ErrCode InstalldClient::GetBundleCachePath(const std::string &dir, std::vector<std::string> &cachePath)
{
if (dir.empty()) {
APP_LOGE("params are invalid");