• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #include "virtual_asset_loader.h"
16 #include "log_print.h"
17 
18 namespace DistributedDB {
Download(const std::string & tableName,const std::string & gid,const Type & prefix,std::map<std::string,Assets> & assets)19 DBStatus VirtualAssetLoader::Download(const std::string &tableName, const std::string &gid, const Type &prefix,
20     std::map<std::string, Assets> &assets)
21 {
22     {
23         std::lock_guard<std::mutex> autoLock(dataMutex_);
24         if (downloadStatus_ != OK) {
25             return downloadStatus_;
26         }
27     }
28     LOGD("Download GID:%s", gid.c_str());
29     for (auto &item: assets) {
30         for (auto &asset: item.second) {
31             LOGD("asset [name]:%s, [status]:%u, [flag]:%u", asset.name.c_str(), asset.status, asset.flag);
32             asset.status = static_cast<uint32_t>(AssetStatus::NORMAL);
33         }
34     }
35     return OK;
36 }
37 
RemoveLocalAssets(const std::vector<Asset> & assets)38 DBStatus VirtualAssetLoader::RemoveLocalAssets(const std::vector<Asset> &assets)
39 {
40     return DBStatus::OK;
41 }
42 
SetDownloadStatus(DBStatus status)43 void VirtualAssetLoader::SetDownloadStatus(DBStatus status)
44 {
45     std::lock_guard<std::mutex> autoLock(dataMutex_);
46     LOGD("[VirtualAssetLoader] set download status :%d", static_cast<int>(status));
47     downloadStatus_ = status;
48 }
49 }
50