1 /* 2 * Copyright (c) 2023-2024 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 "file_column.h" 17 18 namespace OHOS { 19 namespace FileManagement { 20 namespace CloudDisk { 21 const std::string FileColumn::CLOUD_ID = "cloud_id"; 22 const std::string FileColumn::IS_DIRECTORY = "isDirectory"; 23 const std::string FileColumn::FILE_NAME = "file_name"; 24 const std::string FileColumn::PARENT_CLOUD_ID = "parent_cloud_id"; 25 const std::string FileColumn::FILE_SIZE = "file_size"; 26 const std::string FileColumn::FILE_SHA256 = "sha256"; 27 const std::string FileColumn::FILE_TIME_ADDED = "time_added"; 28 const std::string FileColumn::FILE_TIME_EDITED = "time_edited"; 29 const std::string FileColumn::FILE_TIME_RECYCLED = "time_recycled"; 30 const std::string FileColumn::META_TIME_EDITED = "meta_time_edited"; 31 const std::string FileColumn::FILE_TIME_VISIT = "time_visit"; 32 const std::string FileColumn::DIRECTLY_RECYCLED = "directly_recycled"; 33 const std::string FileColumn::VERSION = "version"; 34 const std::string FileColumn::OPERATE_TYPE = "operateType"; 35 const std::string FileColumn::SYNC_STATUS = "sync_status"; 36 const std::string FileColumn::POSITION = "position"; 37 const std::string FileColumn::DIRTY_TYPE = "dirty_type"; 38 const std::string FileColumn::MIME_TYPE = "mimetype"; 39 const std::string FileColumn::FILE_TYPE = "file_type"; 40 const std::string FileColumn::FILE_CATEGORY = "file_category"; 41 const std::string FileColumn::IS_FAVORITE = "isFavorite"; 42 const std::string FileColumn::FILE_STATUS = "file_status"; 43 const std::string FileColumn::ROW_ID = "rowid"; 44 const std::string FileColumn::CHECK_FLAG = "check_flag"; 45 const std::string FileColumn::ROOT_DIRECTORY = "root_directory"; 46 const std::string FileColumn::ATTRIBUTE = "attribute"; 47 const std::string FileColumn::FILES_TABLE = "CloudDisk"; 48 const std::string FileColumn::PARENT_CLOUD_ID_INDEX = "parentCloudId_index"; 49 50 const std::string FileColumn::CREATE_FILE_TABLE = "CREATE TABLE IF NOT EXISTS " + 51 FILES_TABLE + " (" + 52 CLOUD_ID + " TEXT PRIMARY KEY NOT NULL, " + 53 IS_DIRECTORY + " INT, " + 54 FILE_NAME + " TEXT NOT NULL, " + 55 PARENT_CLOUD_ID + " TEXT NOT NULL, " + 56 FILE_SIZE + " BIGINT, " + 57 FILE_SHA256 + " TEXT, " + 58 FILE_TIME_ADDED + " BIGINT, " + 59 FILE_TIME_EDITED + " BIGINT, " + 60 FILE_TIME_RECYCLED + " BIGINT DEFAULT 0, " + 61 META_TIME_EDITED + " BIGINT, " + 62 FILE_TIME_VISIT + " BIGINT DEFAULT 0, " + 63 DIRECTLY_RECYCLED + " INT DEFAULT 0, " + 64 VERSION + " BIGINT DEFAULT 0, " + 65 OPERATE_TYPE + " BIGINT DEFAULT 0, " + 66 SYNC_STATUS + " INT DEFAULT 0, " + 67 POSITION + " INT DEFAULT 1, " + 68 DIRTY_TYPE + " INT DEFAULT 1, " + 69 MIME_TYPE + " TEXT, " + 70 FILE_TYPE + " INT, " + 71 FILE_CATEGORY + " TEXT, " + 72 IS_FAVORITE + " INT DEFAULT 0, " + 73 FILE_STATUS + " INT DEFAULT 4, " + 74 CHECK_FLAG + " INT DEFAULT 0, " + 75 ROOT_DIRECTORY + " TEXT, " + 76 ATTRIBUTE + " TEXT)"; 77 78 const std::string FileColumn::CREATE_PARENT_CLOUD_ID_INDEX = "CREATE INDEX IF NOT EXISTS " + 79 PARENT_CLOUD_ID_INDEX + " ON " + FILES_TABLE + 80 " (" + PARENT_CLOUD_ID + ")"; 81 82 const std::string FileColumn::ADD_IS_FAVORITE = "ALTER Table " + FILES_TABLE + 83 " ADD COLUMN " + IS_FAVORITE + " INT DEFAULT 0"; 84 85 const std::string FileColumn::ADD_FILE_STATUS = "ALTER Table " + FILES_TABLE + 86 " ADD COLUMN " + FILE_STATUS + " INT"; 87 88 const std::string FileColumn::SET_FILE_STATUS_DEFAULT = "UPDATE " + FILES_TABLE + 89 " SET " + FILE_STATUS + " = 4 WHERE " + FILE_STATUS + " IS NULL"; 90 91 const std::string FileColumn::ADD_CHECK_FLAG = "ALTER Table " + FILES_TABLE + 92 " ADD COLUMN " + CHECK_FLAG + " INT DEFAULT 0"; 93 94 const std::string FileColumn::ADD_ATTRIBUTE = "ALTER Table " + FILES_TABLE + 95 " ADD COLUMN " + ATTRIBUTE + " TEXT"; 96 97 const std::vector<std::string> FileColumn::FILE_SYSTEM_QUERY_COLUMNS = { 98 FILE_NAME, 99 CLOUD_ID, 100 PARENT_CLOUD_ID, 101 POSITION, 102 FILE_SIZE, 103 META_TIME_EDITED, 104 FILE_TIME_ADDED, 105 FILE_TIME_EDITED, 106 IS_DIRECTORY, 107 ROW_ID 108 }; 109 110 const std::vector<std::string> FileColumn::DISK_CLOUD_SYNC_COLUMNS = { 111 CLOUD_ID, 112 IS_DIRECTORY, 113 FILE_NAME, 114 PARENT_CLOUD_ID, 115 FILE_SIZE, 116 FILE_SHA256, 117 FILE_TIME_ADDED, 118 FILE_TIME_EDITED, 119 FILE_TIME_RECYCLED, 120 META_TIME_EDITED, 121 DIRECTLY_RECYCLED, 122 VERSION, 123 OPERATE_TYPE, 124 ROOT_DIRECTORY, 125 ATTRIBUTE 126 }; 127 128 const std::vector<std::string> FileColumn::LOCAL_COLUMNS = { 129 FILE_TIME_VISIT, SYNC_STATUS, POSITION, DIRTY_TYPE, 130 MIME_TYPE, IS_DIRECTORY, FILE_TYPE, FILE_CATEGORY, 131 }; 132 133 const std::vector<std::string> FileColumn::PULL_QUERY_COLUMNS = { 134 CLOUD_ID, FILE_TIME_RECYCLED, VERSION, DIRTY_TYPE, POSITION, 135 FILE_TIME_EDITED, FILE_SHA256, FILE_SIZE, FILE_NAME, PARENT_CLOUD_ID, ROW_ID, 136 IS_DIRECTORY, FILE_TIME_ADDED, FILE_TYPE, ROOT_DIRECTORY, DIRECTLY_RECYCLED, 137 }; 138 139 const std::vector<std::string> FileColumn::DISK_ON_UPLOAD_COLUMNS = { 140 CLOUD_ID, 141 PARENT_CLOUD_ID, 142 FILE_NAME, 143 FILE_TIME_EDITED, 144 META_TIME_EDITED, 145 FILE_TIME_RECYCLED, 146 ROW_ID 147 }; 148 149 const std::vector<std::string> FileColumn::EXT_ATTR_QUERY_COLUMNS = { 150 ATTRIBUTE, 151 POSITION 152 }; 153 } // namespace CloudDisk 154 } // namespace FileManagement 155 } // namespace OHOS 156