• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "optimize_cache_task.h"
17 
18 #include "cloud_file_kit.h"
19 #include "parameters.h"
20 #include "system_load.h"
21 #include "utils_log.h"
22 
23 namespace OHOS {
24 namespace FileManagement {
25 namespace CloudSync {
26 static const std::string FILEMANAGER_KEY = "persist.kernel.bundle_name.filemanager";
OptimizeCacheTask(std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager)27 OptimizeCacheTask::OptimizeCacheTask(std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager)
28     : CycleTask("optimize_cache_task",
29                 {GALLERY_BUNDLE_NAME, HDC_BUNDLE_NAME, system::GetParameter(FILEMANAGER_KEY, "")},
30                 ONE_DAY,
31                 dataSyncManager)
32 {}
33 
RunTaskForBundle(int32_t userId,std::string bundleName)34 int32_t OptimizeCacheTask::RunTaskForBundle(int32_t userId, std::string bundleName)
35 {
36     if (!SystemLoadStatus::IsLoadStatusUnderHot()) {
37         LOGE("OptimizeCacheTask::RunTaskForBundle system load is over hot");
38         return E_STOP;
39     }
40     return dataSyncManager_->OptimizeCache(userId, bundleName);
41 }
42 } // namespace CloudSync
43 } // namespace FileManagement
44 } // namespace OHOS