@@ -25,36 +25,36 @@ |
||
| 25 | 25 | * @since 12.0.0 |
| 26 | 26 | */ |
| 27 | 27 | interface ISearchComparison extends ISearchOperator { |
| 28 | - const COMPARE_EQUAL = 'eq'; |
|
| 29 | - const COMPARE_GREATER_THAN = 'gt'; |
|
| 30 | - const COMPARE_GREATER_THAN_EQUAL = 'gte'; |
|
| 31 | - const COMPARE_LESS_THAN = 'lt'; |
|
| 32 | - const COMPARE_LESS_THAN_EQUAL = 'lte'; |
|
| 33 | - const COMPARE_LIKE = 'like'; |
|
| 28 | + const COMPARE_EQUAL = 'eq'; |
|
| 29 | + const COMPARE_GREATER_THAN = 'gt'; |
|
| 30 | + const COMPARE_GREATER_THAN_EQUAL = 'gte'; |
|
| 31 | + const COMPARE_LESS_THAN = 'lt'; |
|
| 32 | + const COMPARE_LESS_THAN_EQUAL = 'lte'; |
|
| 33 | + const COMPARE_LIKE = 'like'; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Get the type of comparison, one of the ISearchComparison::COMPARE_* constants |
|
| 37 | - * |
|
| 38 | - * @return string |
|
| 39 | - * @since 12.0.0 |
|
| 40 | - */ |
|
| 41 | - public function getType(); |
|
| 35 | + /** |
|
| 36 | + * Get the type of comparison, one of the ISearchComparison::COMPARE_* constants |
|
| 37 | + * |
|
| 38 | + * @return string |
|
| 39 | + * @since 12.0.0 |
|
| 40 | + */ |
|
| 41 | + public function getType(); |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Get the name of the field to compare with |
|
| 45 | - * |
|
| 46 | - * i.e. 'size', 'name' or 'mimetype' |
|
| 47 | - * |
|
| 48 | - * @return string |
|
| 49 | - * @since 12.0.0 |
|
| 50 | - */ |
|
| 51 | - public function getField(); |
|
| 43 | + /** |
|
| 44 | + * Get the name of the field to compare with |
|
| 45 | + * |
|
| 46 | + * i.e. 'size', 'name' or 'mimetype' |
|
| 47 | + * |
|
| 48 | + * @return string |
|
| 49 | + * @since 12.0.0 |
|
| 50 | + */ |
|
| 51 | + public function getField(); |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Get the value to compare the field with |
|
| 55 | - * |
|
| 56 | - * @return string|integer|\DateTime |
|
| 57 | - * @since 12.0.0 |
|
| 58 | - */ |
|
| 59 | - public function getValue(); |
|
| 53 | + /** |
|
| 54 | + * Get the value to compare the field with |
|
| 55 | + * |
|
| 56 | + * @return string|integer|\DateTime |
|
| 57 | + * @since 12.0.0 |
|
| 58 | + */ |
|
| 59 | + public function getValue(); |
|
| 60 | 60 | } |
@@ -25,27 +25,27 @@ |
||
| 25 | 25 | * @since 12.0.0 |
| 26 | 26 | */ |
| 27 | 27 | interface ISearchBinaryOperator extends ISearchOperator { |
| 28 | - const OPERATOR_AND = 'and'; |
|
| 29 | - const OPERATOR_OR = 'or'; |
|
| 30 | - const OPERATOR_NOT = 'not'; |
|
| 28 | + const OPERATOR_AND = 'and'; |
|
| 29 | + const OPERATOR_OR = 'or'; |
|
| 30 | + const OPERATOR_NOT = 'not'; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * The type of binary operator |
|
| 34 | - * |
|
| 35 | - * One of the ISearchBinaryOperator::OPERATOR_* constants |
|
| 36 | - * |
|
| 37 | - * @return string |
|
| 38 | - * @since 12.0.0 |
|
| 39 | - */ |
|
| 40 | - public function getType(); |
|
| 32 | + /** |
|
| 33 | + * The type of binary operator |
|
| 34 | + * |
|
| 35 | + * One of the ISearchBinaryOperator::OPERATOR_* constants |
|
| 36 | + * |
|
| 37 | + * @return string |
|
| 38 | + * @since 12.0.0 |
|
| 39 | + */ |
|
| 40 | + public function getType(); |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * The arguments for the binary operator |
|
| 44 | - * |
|
| 45 | - * One argument for the 'not' operator and two for 'and' and 'or' |
|
| 46 | - * |
|
| 47 | - * @return ISearchOperator[] |
|
| 48 | - * @since 12.0.0 |
|
| 49 | - */ |
|
| 50 | - public function getArguments(); |
|
| 42 | + /** |
|
| 43 | + * The arguments for the binary operator |
|
| 44 | + * |
|
| 45 | + * One argument for the 'not' operator and two for 'and' and 'or' |
|
| 46 | + * |
|
| 47 | + * @return ISearchOperator[] |
|
| 48 | + * @since 12.0.0 |
|
| 49 | + */ |
|
| 50 | + public function getArguments(); |
|
| 51 | 51 | } |
@@ -37,233 +37,233 @@ |
||
| 37 | 37 | * @since 9.0.0 |
| 38 | 38 | */ |
| 39 | 39 | interface ICache { |
| 40 | - const NOT_FOUND = 0; |
|
| 41 | - const PARTIAL = 1; //only partial data available, file not cached in the database |
|
| 42 | - const SHALLOW = 2; //folder in cache, but not all child files are completely scanned |
|
| 43 | - const COMPLETE = 3; |
|
| 40 | + const NOT_FOUND = 0; |
|
| 41 | + const PARTIAL = 1; //only partial data available, file not cached in the database |
|
| 42 | + const SHALLOW = 2; //folder in cache, but not all child files are completely scanned |
|
| 43 | + const COMPLETE = 3; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Get the numeric storage id for this cache's storage |
|
| 47 | - * |
|
| 48 | - * @return int |
|
| 49 | - * @since 9.0.0 |
|
| 50 | - */ |
|
| 51 | - public function getNumericStorageId(); |
|
| 45 | + /** |
|
| 46 | + * Get the numeric storage id for this cache's storage |
|
| 47 | + * |
|
| 48 | + * @return int |
|
| 49 | + * @since 9.0.0 |
|
| 50 | + */ |
|
| 51 | + public function getNumericStorageId(); |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * get the stored metadata of a file or folder |
|
| 55 | - * |
|
| 56 | - * @param string | int $file either the path of a file or folder or the file id for a file or folder |
|
| 57 | - * @return ICacheEntry|false the cache entry or false if the file is not found in the cache |
|
| 58 | - * @since 9.0.0 |
|
| 59 | - */ |
|
| 60 | - public function get($file); |
|
| 53 | + /** |
|
| 54 | + * get the stored metadata of a file or folder |
|
| 55 | + * |
|
| 56 | + * @param string | int $file either the path of a file or folder or the file id for a file or folder |
|
| 57 | + * @return ICacheEntry|false the cache entry or false if the file is not found in the cache |
|
| 58 | + * @since 9.0.0 |
|
| 59 | + */ |
|
| 60 | + public function get($file); |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * get the metadata of all files stored in $folder |
|
| 64 | - * |
|
| 65 | - * Only returns files one level deep, no recursion |
|
| 66 | - * |
|
| 67 | - * @param string $folder |
|
| 68 | - * @return ICacheEntry[] |
|
| 69 | - * @since 9.0.0 |
|
| 70 | - */ |
|
| 71 | - public function getFolderContents($folder); |
|
| 62 | + /** |
|
| 63 | + * get the metadata of all files stored in $folder |
|
| 64 | + * |
|
| 65 | + * Only returns files one level deep, no recursion |
|
| 66 | + * |
|
| 67 | + * @param string $folder |
|
| 68 | + * @return ICacheEntry[] |
|
| 69 | + * @since 9.0.0 |
|
| 70 | + */ |
|
| 71 | + public function getFolderContents($folder); |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * get the metadata of all files stored in $folder |
|
| 75 | - * |
|
| 76 | - * Only returns files one level deep, no recursion |
|
| 77 | - * |
|
| 78 | - * @param int $fileId the file id of the folder |
|
| 79 | - * @return ICacheEntry[] |
|
| 80 | - * @since 9.0.0 |
|
| 81 | - */ |
|
| 82 | - public function getFolderContentsById($fileId); |
|
| 73 | + /** |
|
| 74 | + * get the metadata of all files stored in $folder |
|
| 75 | + * |
|
| 76 | + * Only returns files one level deep, no recursion |
|
| 77 | + * |
|
| 78 | + * @param int $fileId the file id of the folder |
|
| 79 | + * @return ICacheEntry[] |
|
| 80 | + * @since 9.0.0 |
|
| 81 | + */ |
|
| 82 | + public function getFolderContentsById($fileId); |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * store meta data for a file or folder |
|
| 86 | - * This will automatically call either insert or update depending on if the file exists |
|
| 87 | - * |
|
| 88 | - * @param string $file |
|
| 89 | - * @param array $data |
|
| 90 | - * |
|
| 91 | - * @return int file id |
|
| 92 | - * @throws \RuntimeException |
|
| 93 | - * @since 9.0.0 |
|
| 94 | - */ |
|
| 95 | - public function put($file, array $data); |
|
| 84 | + /** |
|
| 85 | + * store meta data for a file or folder |
|
| 86 | + * This will automatically call either insert or update depending on if the file exists |
|
| 87 | + * |
|
| 88 | + * @param string $file |
|
| 89 | + * @param array $data |
|
| 90 | + * |
|
| 91 | + * @return int file id |
|
| 92 | + * @throws \RuntimeException |
|
| 93 | + * @since 9.0.0 |
|
| 94 | + */ |
|
| 95 | + public function put($file, array $data); |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * insert meta data for a new file or folder |
|
| 99 | - * |
|
| 100 | - * @param string $file |
|
| 101 | - * @param array $data |
|
| 102 | - * |
|
| 103 | - * @return int file id |
|
| 104 | - * @throws \RuntimeException |
|
| 105 | - * @since 9.0.0 |
|
| 106 | - */ |
|
| 107 | - public function insert($file, array $data); |
|
| 97 | + /** |
|
| 98 | + * insert meta data for a new file or folder |
|
| 99 | + * |
|
| 100 | + * @param string $file |
|
| 101 | + * @param array $data |
|
| 102 | + * |
|
| 103 | + * @return int file id |
|
| 104 | + * @throws \RuntimeException |
|
| 105 | + * @since 9.0.0 |
|
| 106 | + */ |
|
| 107 | + public function insert($file, array $data); |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * update the metadata of an existing file or folder in the cache |
|
| 111 | - * |
|
| 112 | - * @param int $id the fileid of the existing file or folder |
|
| 113 | - * @param array $data [$key => $value] the metadata to update, only the fields provided in the array will be updated, non-provided values will remain unchanged |
|
| 114 | - * @since 9.0.0 |
|
| 115 | - */ |
|
| 116 | - public function update($id, array $data); |
|
| 109 | + /** |
|
| 110 | + * update the metadata of an existing file or folder in the cache |
|
| 111 | + * |
|
| 112 | + * @param int $id the fileid of the existing file or folder |
|
| 113 | + * @param array $data [$key => $value] the metadata to update, only the fields provided in the array will be updated, non-provided values will remain unchanged |
|
| 114 | + * @since 9.0.0 |
|
| 115 | + */ |
|
| 116 | + public function update($id, array $data); |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * get the file id for a file |
|
| 120 | - * |
|
| 121 | - * A file id is a numeric id for a file or folder that's unique within an owncloud instance which stays the same for the lifetime of a file |
|
| 122 | - * |
|
| 123 | - * File ids are easiest way for apps to store references to a file since unlike paths they are not affected by renames or sharing |
|
| 124 | - * |
|
| 125 | - * @param string $file |
|
| 126 | - * @return int |
|
| 127 | - * @since 9.0.0 |
|
| 128 | - */ |
|
| 129 | - public function getId($file); |
|
| 118 | + /** |
|
| 119 | + * get the file id for a file |
|
| 120 | + * |
|
| 121 | + * A file id is a numeric id for a file or folder that's unique within an owncloud instance which stays the same for the lifetime of a file |
|
| 122 | + * |
|
| 123 | + * File ids are easiest way for apps to store references to a file since unlike paths they are not affected by renames or sharing |
|
| 124 | + * |
|
| 125 | + * @param string $file |
|
| 126 | + * @return int |
|
| 127 | + * @since 9.0.0 |
|
| 128 | + */ |
|
| 129 | + public function getId($file); |
|
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * get the id of the parent folder of a file |
|
| 133 | - * |
|
| 134 | - * @param string $file |
|
| 135 | - * @return int |
|
| 136 | - * @since 9.0.0 |
|
| 137 | - */ |
|
| 138 | - public function getParentId($file); |
|
| 131 | + /** |
|
| 132 | + * get the id of the parent folder of a file |
|
| 133 | + * |
|
| 134 | + * @param string $file |
|
| 135 | + * @return int |
|
| 136 | + * @since 9.0.0 |
|
| 137 | + */ |
|
| 138 | + public function getParentId($file); |
|
| 139 | 139 | |
| 140 | - /** |
|
| 141 | - * check if a file is available in the cache |
|
| 142 | - * |
|
| 143 | - * @param string $file |
|
| 144 | - * @return bool |
|
| 145 | - * @since 9.0.0 |
|
| 146 | - */ |
|
| 147 | - public function inCache($file); |
|
| 140 | + /** |
|
| 141 | + * check if a file is available in the cache |
|
| 142 | + * |
|
| 143 | + * @param string $file |
|
| 144 | + * @return bool |
|
| 145 | + * @since 9.0.0 |
|
| 146 | + */ |
|
| 147 | + public function inCache($file); |
|
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * remove a file or folder from the cache |
|
| 151 | - * |
|
| 152 | - * when removing a folder from the cache all files and folders inside the folder will be removed as well |
|
| 153 | - * |
|
| 154 | - * @param string $file |
|
| 155 | - * @since 9.0.0 |
|
| 156 | - */ |
|
| 157 | - public function remove($file); |
|
| 149 | + /** |
|
| 150 | + * remove a file or folder from the cache |
|
| 151 | + * |
|
| 152 | + * when removing a folder from the cache all files and folders inside the folder will be removed as well |
|
| 153 | + * |
|
| 154 | + * @param string $file |
|
| 155 | + * @since 9.0.0 |
|
| 156 | + */ |
|
| 157 | + public function remove($file); |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Move a file or folder in the cache |
|
| 161 | - * |
|
| 162 | - * @param string $source |
|
| 163 | - * @param string $target |
|
| 164 | - * @since 9.0.0 |
|
| 165 | - */ |
|
| 166 | - public function move($source, $target); |
|
| 159 | + /** |
|
| 160 | + * Move a file or folder in the cache |
|
| 161 | + * |
|
| 162 | + * @param string $source |
|
| 163 | + * @param string $target |
|
| 164 | + * @since 9.0.0 |
|
| 165 | + */ |
|
| 166 | + public function move($source, $target); |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Move a file or folder in the cache |
|
| 170 | - * |
|
| 171 | - * Note that this should make sure the entries are removed from the source cache |
|
| 172 | - * |
|
| 173 | - * @param \OCP\Files\Cache\ICache $sourceCache |
|
| 174 | - * @param string $sourcePath |
|
| 175 | - * @param string $targetPath |
|
| 176 | - * @throws \OC\DatabaseException |
|
| 177 | - * @since 9.0.0 |
|
| 178 | - */ |
|
| 179 | - public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath); |
|
| 168 | + /** |
|
| 169 | + * Move a file or folder in the cache |
|
| 170 | + * |
|
| 171 | + * Note that this should make sure the entries are removed from the source cache |
|
| 172 | + * |
|
| 173 | + * @param \OCP\Files\Cache\ICache $sourceCache |
|
| 174 | + * @param string $sourcePath |
|
| 175 | + * @param string $targetPath |
|
| 176 | + * @throws \OC\DatabaseException |
|
| 177 | + * @since 9.0.0 |
|
| 178 | + */ |
|
| 179 | + public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath); |
|
| 180 | 180 | |
| 181 | - /** |
|
| 182 | - * Get the scan status of a file |
|
| 183 | - * |
|
| 184 | - * - ICache::NOT_FOUND: File is not in the cache |
|
| 185 | - * - ICache::PARTIAL: File is not stored in the cache but some incomplete data is known |
|
| 186 | - * - ICache::SHALLOW: The folder and it's direct children are in the cache but not all sub folders are fully scanned |
|
| 187 | - * - ICache::COMPLETE: The file or folder, with all it's children) are fully scanned |
|
| 188 | - * |
|
| 189 | - * @param string $file |
|
| 190 | - * |
|
| 191 | - * @return int ICache::NOT_FOUND, ICache::PARTIAL, ICache::SHALLOW or ICache::COMPLETE |
|
| 192 | - * @since 9.0.0 |
|
| 193 | - */ |
|
| 194 | - public function getStatus($file); |
|
| 181 | + /** |
|
| 182 | + * Get the scan status of a file |
|
| 183 | + * |
|
| 184 | + * - ICache::NOT_FOUND: File is not in the cache |
|
| 185 | + * - ICache::PARTIAL: File is not stored in the cache but some incomplete data is known |
|
| 186 | + * - ICache::SHALLOW: The folder and it's direct children are in the cache but not all sub folders are fully scanned |
|
| 187 | + * - ICache::COMPLETE: The file or folder, with all it's children) are fully scanned |
|
| 188 | + * |
|
| 189 | + * @param string $file |
|
| 190 | + * |
|
| 191 | + * @return int ICache::NOT_FOUND, ICache::PARTIAL, ICache::SHALLOW or ICache::COMPLETE |
|
| 192 | + * @since 9.0.0 |
|
| 193 | + */ |
|
| 194 | + public function getStatus($file); |
|
| 195 | 195 | |
| 196 | - /** |
|
| 197 | - * search for files matching $pattern, files are matched if their filename matches the search pattern |
|
| 198 | - * |
|
| 199 | - * @param string $pattern the search pattern using SQL search syntax (e.g. '%searchstring%') |
|
| 200 | - * @return ICacheEntry[] an array of cache entries where the name matches the search pattern |
|
| 201 | - * @since 9.0.0 |
|
| 202 | - * @deprecated 9.0.0 due to lack of pagination, not all backends might implement this |
|
| 203 | - */ |
|
| 204 | - public function search($pattern); |
|
| 196 | + /** |
|
| 197 | + * search for files matching $pattern, files are matched if their filename matches the search pattern |
|
| 198 | + * |
|
| 199 | + * @param string $pattern the search pattern using SQL search syntax (e.g. '%searchstring%') |
|
| 200 | + * @return ICacheEntry[] an array of cache entries where the name matches the search pattern |
|
| 201 | + * @since 9.0.0 |
|
| 202 | + * @deprecated 9.0.0 due to lack of pagination, not all backends might implement this |
|
| 203 | + */ |
|
| 204 | + public function search($pattern); |
|
| 205 | 205 | |
| 206 | - /** |
|
| 207 | - * search for files by mimetype |
|
| 208 | - * |
|
| 209 | - * @param string $mimetype either a full mimetype to search ('text/plain') or only the first part of a mimetype ('image') |
|
| 210 | - * where it will search for all mimetypes in the group ('image/*') |
|
| 211 | - * @return ICacheEntry[] an array of cache entries where the mimetype matches the search |
|
| 212 | - * @since 9.0.0 |
|
| 213 | - * @deprecated 9.0.0 due to lack of pagination, not all backends might implement this |
|
| 214 | - */ |
|
| 215 | - public function searchByMime($mimetype); |
|
| 206 | + /** |
|
| 207 | + * search for files by mimetype |
|
| 208 | + * |
|
| 209 | + * @param string $mimetype either a full mimetype to search ('text/plain') or only the first part of a mimetype ('image') |
|
| 210 | + * where it will search for all mimetypes in the group ('image/*') |
|
| 211 | + * @return ICacheEntry[] an array of cache entries where the mimetype matches the search |
|
| 212 | + * @since 9.0.0 |
|
| 213 | + * @deprecated 9.0.0 due to lack of pagination, not all backends might implement this |
|
| 214 | + */ |
|
| 215 | + public function searchByMime($mimetype); |
|
| 216 | 216 | |
| 217 | - /** |
|
| 218 | - * Search for files with a flexible query |
|
| 219 | - * |
|
| 220 | - * @param ISearchQuery $query |
|
| 221 | - * @return ICacheEntry[] |
|
| 222 | - * @throw \InvalidArgumentException if the cache is unable to perform the query |
|
| 223 | - * @since 12.0.0 |
|
| 224 | - */ |
|
| 225 | - public function searchQuery(ISearchQuery $query); |
|
| 217 | + /** |
|
| 218 | + * Search for files with a flexible query |
|
| 219 | + * |
|
| 220 | + * @param ISearchQuery $query |
|
| 221 | + * @return ICacheEntry[] |
|
| 222 | + * @throw \InvalidArgumentException if the cache is unable to perform the query |
|
| 223 | + * @since 12.0.0 |
|
| 224 | + */ |
|
| 225 | + public function searchQuery(ISearchQuery $query); |
|
| 226 | 226 | |
| 227 | - /** |
|
| 228 | - * Search for files by tag of a given users. |
|
| 229 | - * |
|
| 230 | - * Note that every user can tag files differently. |
|
| 231 | - * |
|
| 232 | - * @param string|int $tag name or tag id |
|
| 233 | - * @param string $userId owner of the tags |
|
| 234 | - * @return ICacheEntry[] file data |
|
| 235 | - * @since 9.0.0 |
|
| 236 | - * @deprecated 9.0.0 due to lack of pagination, not all backends might implement this |
|
| 237 | - */ |
|
| 238 | - public function searchByTag($tag, $userId); |
|
| 227 | + /** |
|
| 228 | + * Search for files by tag of a given users. |
|
| 229 | + * |
|
| 230 | + * Note that every user can tag files differently. |
|
| 231 | + * |
|
| 232 | + * @param string|int $tag name or tag id |
|
| 233 | + * @param string $userId owner of the tags |
|
| 234 | + * @return ICacheEntry[] file data |
|
| 235 | + * @since 9.0.0 |
|
| 236 | + * @deprecated 9.0.0 due to lack of pagination, not all backends might implement this |
|
| 237 | + */ |
|
| 238 | + public function searchByTag($tag, $userId); |
|
| 239 | 239 | |
| 240 | - /** |
|
| 241 | - * find a folder in the cache which has not been fully scanned |
|
| 242 | - * |
|
| 243 | - * If multiple incomplete folders are in the cache, the one with the highest id will be returned, |
|
| 244 | - * use the one with the highest id gives the best result with the background scanner, since that is most |
|
| 245 | - * likely the folder where we stopped scanning previously |
|
| 246 | - * |
|
| 247 | - * @return string|bool the path of the folder or false when no folder matched |
|
| 248 | - * @since 9.0.0 |
|
| 249 | - */ |
|
| 250 | - public function getIncomplete(); |
|
| 240 | + /** |
|
| 241 | + * find a folder in the cache which has not been fully scanned |
|
| 242 | + * |
|
| 243 | + * If multiple incomplete folders are in the cache, the one with the highest id will be returned, |
|
| 244 | + * use the one with the highest id gives the best result with the background scanner, since that is most |
|
| 245 | + * likely the folder where we stopped scanning previously |
|
| 246 | + * |
|
| 247 | + * @return string|bool the path of the folder or false when no folder matched |
|
| 248 | + * @since 9.0.0 |
|
| 249 | + */ |
|
| 250 | + public function getIncomplete(); |
|
| 251 | 251 | |
| 252 | - /** |
|
| 253 | - * get the path of a file on this storage by it's file id |
|
| 254 | - * |
|
| 255 | - * @param int $id the file id of the file or folder to search |
|
| 256 | - * @return string|null the path of the file (relative to the storage) or null if a file with the given id does not exists within this cache |
|
| 257 | - * @since 9.0.0 |
|
| 258 | - */ |
|
| 259 | - public function getPathById($id); |
|
| 252 | + /** |
|
| 253 | + * get the path of a file on this storage by it's file id |
|
| 254 | + * |
|
| 255 | + * @param int $id the file id of the file or folder to search |
|
| 256 | + * @return string|null the path of the file (relative to the storage) or null if a file with the given id does not exists within this cache |
|
| 257 | + * @since 9.0.0 |
|
| 258 | + */ |
|
| 259 | + public function getPathById($id); |
|
| 260 | 260 | |
| 261 | - /** |
|
| 262 | - * normalize the given path for usage in the cache |
|
| 263 | - * |
|
| 264 | - * @param string $path |
|
| 265 | - * @return string |
|
| 266 | - * @since 9.0.0 |
|
| 267 | - */ |
|
| 268 | - public function normalize($path); |
|
| 261 | + /** |
|
| 262 | + * normalize the given path for usage in the cache |
|
| 263 | + * |
|
| 264 | + * @param string $path |
|
| 265 | + * @return string |
|
| 266 | + * @since 9.0.0 |
|
| 267 | + */ |
|
| 268 | + public function normalize($path); |
|
| 269 | 269 | } |
@@ -24,44 +24,44 @@ |
||
| 24 | 24 | use OCP\Files\Search\ISearchComparison; |
| 25 | 25 | |
| 26 | 26 | class SearchComparison implements ISearchComparison { |
| 27 | - /** @var string */ |
|
| 28 | - private $type; |
|
| 29 | - /** @var string */ |
|
| 30 | - private $field; |
|
| 31 | - /** @var string|integer|\DateTime */ |
|
| 32 | - private $value; |
|
| 27 | + /** @var string */ |
|
| 28 | + private $type; |
|
| 29 | + /** @var string */ |
|
| 30 | + private $field; |
|
| 31 | + /** @var string|integer|\DateTime */ |
|
| 32 | + private $value; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * SearchComparison constructor. |
|
| 36 | - * |
|
| 37 | - * @param string $type |
|
| 38 | - * @param string $field |
|
| 39 | - * @param \DateTime|int|string $value |
|
| 40 | - */ |
|
| 41 | - public function __construct($type, $field, $value) { |
|
| 42 | - $this->type = $type; |
|
| 43 | - $this->field = $field; |
|
| 44 | - $this->value = $value; |
|
| 45 | - } |
|
| 34 | + /** |
|
| 35 | + * SearchComparison constructor. |
|
| 36 | + * |
|
| 37 | + * @param string $type |
|
| 38 | + * @param string $field |
|
| 39 | + * @param \DateTime|int|string $value |
|
| 40 | + */ |
|
| 41 | + public function __construct($type, $field, $value) { |
|
| 42 | + $this->type = $type; |
|
| 43 | + $this->field = $field; |
|
| 44 | + $this->value = $value; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @return string |
|
| 49 | - */ |
|
| 50 | - public function getType() { |
|
| 51 | - return $this->type; |
|
| 52 | - } |
|
| 47 | + /** |
|
| 48 | + * @return string |
|
| 49 | + */ |
|
| 50 | + public function getType() { |
|
| 51 | + return $this->type; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 57 | - public function getField() { |
|
| 58 | - return $this->field; |
|
| 59 | - } |
|
| 54 | + /** |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | + public function getField() { |
|
| 58 | + return $this->field; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @return \DateTime|int|string |
|
| 63 | - */ |
|
| 64 | - public function getValue() { |
|
| 65 | - return $this->value; |
|
| 66 | - } |
|
| 61 | + /** |
|
| 62 | + * @return \DateTime|int|string |
|
| 63 | + */ |
|
| 64 | + public function getValue() { |
|
| 65 | + return $this->value; |
|
| 66 | + } |
|
| 67 | 67 | } |
@@ -25,33 +25,33 @@ |
||
| 25 | 25 | use OCP\Files\Search\ISearchOrder; |
| 26 | 26 | |
| 27 | 27 | class SearchOrder implements ISearchOrder { |
| 28 | - /** @var string */ |
|
| 29 | - private $direction; |
|
| 30 | - /** @var string */ |
|
| 31 | - private $field; |
|
| 28 | + /** @var string */ |
|
| 29 | + private $direction; |
|
| 30 | + /** @var string */ |
|
| 31 | + private $field; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * SearchOrder constructor. |
|
| 35 | - * |
|
| 36 | - * @param string $direction |
|
| 37 | - * @param string $field |
|
| 38 | - */ |
|
| 39 | - public function __construct($direction, $field) { |
|
| 40 | - $this->direction = $direction; |
|
| 41 | - $this->field = $field; |
|
| 42 | - } |
|
| 33 | + /** |
|
| 34 | + * SearchOrder constructor. |
|
| 35 | + * |
|
| 36 | + * @param string $direction |
|
| 37 | + * @param string $field |
|
| 38 | + */ |
|
| 39 | + public function __construct($direction, $field) { |
|
| 40 | + $this->direction = $direction; |
|
| 41 | + $this->field = $field; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @return string |
|
| 46 | - */ |
|
| 47 | - public function getDirection() { |
|
| 48 | - return $this->direction; |
|
| 49 | - } |
|
| 44 | + /** |
|
| 45 | + * @return string |
|
| 46 | + */ |
|
| 47 | + public function getDirection() { |
|
| 48 | + return $this->direction; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @return string |
|
| 53 | - */ |
|
| 54 | - public function getField() { |
|
| 55 | - return $this->field; |
|
| 56 | - } |
|
| 51 | + /** |
|
| 52 | + * @return string |
|
| 53 | + */ |
|
| 54 | + public function getField() { |
|
| 55 | + return $this->field; |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -25,33 +25,33 @@ |
||
| 25 | 25 | use OCP\Files\Search\ISearchOperator; |
| 26 | 26 | |
| 27 | 27 | class SearchBinaryOperator implements ISearchBinaryOperator { |
| 28 | - /** @var string */ |
|
| 29 | - private $type; |
|
| 30 | - /** @var ISearchOperator[] */ |
|
| 31 | - private $arguments; |
|
| 28 | + /** @var string */ |
|
| 29 | + private $type; |
|
| 30 | + /** @var ISearchOperator[] */ |
|
| 31 | + private $arguments; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * SearchBinaryOperator constructor. |
|
| 35 | - * |
|
| 36 | - * @param string $type |
|
| 37 | - * @param ISearchOperator[] $arguments |
|
| 38 | - */ |
|
| 39 | - public function __construct($type, array $arguments) { |
|
| 40 | - $this->type = $type; |
|
| 41 | - $this->arguments = $arguments; |
|
| 42 | - } |
|
| 33 | + /** |
|
| 34 | + * SearchBinaryOperator constructor. |
|
| 35 | + * |
|
| 36 | + * @param string $type |
|
| 37 | + * @param ISearchOperator[] $arguments |
|
| 38 | + */ |
|
| 39 | + public function __construct($type, array $arguments) { |
|
| 40 | + $this->type = $type; |
|
| 41 | + $this->arguments = $arguments; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @return string |
|
| 46 | - */ |
|
| 47 | - public function getType() { |
|
| 48 | - return $this->type; |
|
| 49 | - } |
|
| 44 | + /** |
|
| 45 | + * @return string |
|
| 46 | + */ |
|
| 47 | + public function getType() { |
|
| 48 | + return $this->type; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @return ISearchOperator[] |
|
| 53 | - */ |
|
| 54 | - public function getArguments() { |
|
| 55 | - return $this->arguments; |
|
| 56 | - } |
|
| 51 | + /** |
|
| 52 | + * @return ISearchOperator[] |
|
| 53 | + */ |
|
| 54 | + public function getArguments() { |
|
| 55 | + return $this->arguments; |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -27,101 +27,101 @@ |
||
| 27 | 27 | use OCP\Files\Search\ISearchQuery; |
| 28 | 28 | |
| 29 | 29 | class NullCache implements ICache { |
| 30 | - public function getNumericStorageId() { |
|
| 31 | - return -1; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - public function get($file) { |
|
| 35 | - return $file !== '' ? null : |
|
| 36 | - new CacheEntry([ |
|
| 37 | - 'fileid' => -1, |
|
| 38 | - 'parent' => -1, |
|
| 39 | - 'name' => '', |
|
| 40 | - 'path' => '', |
|
| 41 | - 'size' => '0', |
|
| 42 | - 'mtime' => time(), |
|
| 43 | - 'storage_mtime' => time(), |
|
| 44 | - 'etag' => '', |
|
| 45 | - 'mimetype' => FileInfo::MIMETYPE_FOLDER, |
|
| 46 | - 'mimepart' => 'httpd', |
|
| 47 | - 'permissions' => Constants::PERMISSION_READ |
|
| 48 | - ]); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public function getFolderContents($folder) { |
|
| 52 | - return []; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - public function getFolderContentsById($fileId) { |
|
| 56 | - return []; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - public function put($file, array $data) { |
|
| 60 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - public function insert($file, array $data) { |
|
| 64 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - public function update($id, array $data) { |
|
| 68 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - public function getId($file) { |
|
| 72 | - return -1; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - public function getParentId($file) { |
|
| 76 | - return -1; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - public function inCache($file) { |
|
| 80 | - return $file === ''; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - public function remove($file) { |
|
| 84 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - public function move($source, $target) { |
|
| 88 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { |
|
| 92 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - public function getStatus($file) { |
|
| 96 | - return ICache::COMPLETE; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - public function search($pattern) { |
|
| 100 | - return []; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - public function searchByMime($mimetype) { |
|
| 104 | - return []; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - public function searchQuery(ISearchQuery $query) { |
|
| 108 | - return []; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - public function searchByTag($tag, $userId) { |
|
| 112 | - return []; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - public function getIncomplete() { |
|
| 116 | - return []; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - public function getPathById($id) { |
|
| 120 | - return ''; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - public function normalize($path) { |
|
| 124 | - return $path; |
|
| 125 | - } |
|
| 30 | + public function getNumericStorageId() { |
|
| 31 | + return -1; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + public function get($file) { |
|
| 35 | + return $file !== '' ? null : |
|
| 36 | + new CacheEntry([ |
|
| 37 | + 'fileid' => -1, |
|
| 38 | + 'parent' => -1, |
|
| 39 | + 'name' => '', |
|
| 40 | + 'path' => '', |
|
| 41 | + 'size' => '0', |
|
| 42 | + 'mtime' => time(), |
|
| 43 | + 'storage_mtime' => time(), |
|
| 44 | + 'etag' => '', |
|
| 45 | + 'mimetype' => FileInfo::MIMETYPE_FOLDER, |
|
| 46 | + 'mimepart' => 'httpd', |
|
| 47 | + 'permissions' => Constants::PERMISSION_READ |
|
| 48 | + ]); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public function getFolderContents($folder) { |
|
| 52 | + return []; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + public function getFolderContentsById($fileId) { |
|
| 56 | + return []; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + public function put($file, array $data) { |
|
| 60 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + public function insert($file, array $data) { |
|
| 64 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + public function update($id, array $data) { |
|
| 68 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + public function getId($file) { |
|
| 72 | + return -1; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + public function getParentId($file) { |
|
| 76 | + return -1; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + public function inCache($file) { |
|
| 80 | + return $file === ''; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + public function remove($file) { |
|
| 84 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + public function move($source, $target) { |
|
| 88 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { |
|
| 92 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + public function getStatus($file) { |
|
| 96 | + return ICache::COMPLETE; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + public function search($pattern) { |
|
| 100 | + return []; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + public function searchByMime($mimetype) { |
|
| 104 | + return []; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + public function searchQuery(ISearchQuery $query) { |
|
| 108 | + return []; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + public function searchByTag($tag, $userId) { |
|
| 112 | + return []; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + public function getIncomplete() { |
|
| 116 | + return []; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + public function getPathById($id) { |
|
| 120 | + return ''; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + public function normalize($path) { |
|
| 124 | + return $path; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | 127 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | <div class="warning title"> |
| 19 | 19 | <?php p($l->t('Please renew your password.')); ?><br> |
| 20 | 20 | </div> |
| 21 | - <?php foreach($_['messages'] as $message): ?> |
|
| 21 | + <?php foreach ($_['messages'] as $message): ?> |
|
| 22 | 22 | <div class="warning"> |
| 23 | 23 | <?php p($message); ?><br> |
| 24 | 24 | </div> |
@@ -31,14 +31,14 @@ discard block |
||
| 31 | 31 | <?php endif; ?> |
| 32 | 32 | <div id="message" class="hidden"> |
| 33 | 33 | <img class="float-spinner" alt="" |
| 34 | - src="<?php p(image_path('core', 'loading-dark.gif'));?>"> |
|
| 34 | + src="<?php p(image_path('core', 'loading-dark.gif')); ?>"> |
|
| 35 | 35 | <span id="messageText"></span> |
| 36 | 36 | <!-- the following div ensures that the spinner is always inside the #message div --> |
| 37 | 37 | <div style="clear: both;"></div> |
| 38 | 38 | </div> |
| 39 | 39 | <p class="grouptop"> |
| 40 | 40 | <input type="password" id="oldPassword" name="oldPassword" |
| 41 | - placeholder="<?php echo $l->t('Current password');?>" |
|
| 41 | + placeholder="<?php echo $l->t('Current password'); ?>" |
|
| 42 | 42 | autofocus autocomplete="off" autocapitalize="off" autocorrect="off" required/> |
| 43 | 43 | <label for="oldPassword" class="infield"><?php p($l->t('Current password')); ?></label> |
| 44 | 44 | </p> |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | <input type="checkbox" id="personal-show" name="show" /><label for="personal-show"></label> |
| 48 | 48 | <label id="newPassword-label" for="newPassword" class="infield"><?php p($l->t('New password')); ?></label> |
| 49 | 49 | <input type="password" id="newPassword" name="newPassword" |
| 50 | - placeholder="<?php echo $l->t('New password');?>" |
|
| 50 | + placeholder="<?php echo $l->t('New password'); ?>" |
|
| 51 | 51 | data-typetoggle="#personal-show" autofocus autocomplete="off" autocapitalize="off" autocorrect="off" required/> |
| 52 | 52 | </p> |
| 53 | 53 | |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php /** @var $l OC_L10N */ ?> |
| 2 | 2 | <?php |
| 3 | 3 | script('user_ldap', [ |
| 4 | - 'renewPassword', |
|
| 4 | + 'renewPassword', |
|
| 5 | 5 | ]); |
| 6 | 6 | style('user_ldap', 'renewPassword'); |
| 7 | 7 | ?> |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | $updatedEntries = $builder->execute(); |
| 73 | 73 | if ($updatedEntries > 0) { |
| 74 | - $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
| 74 | + $out->info('Fixed file share permissions for '.$updatedEntries.' shares'); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | if ($deletedEntries) { |
| 110 | - $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
| 110 | + $out->info('Removed '.$deletedEntries.' shares where the parent did not exist'); |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
@@ -33,90 +33,90 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class RepairInvalidShares implements IRepairStep { |
| 35 | 35 | |
| 36 | - const CHUNK_SIZE = 200; |
|
| 37 | - |
|
| 38 | - /** @var \OCP\IConfig */ |
|
| 39 | - protected $config; |
|
| 40 | - |
|
| 41 | - /** @var \OCP\IDBConnection */ |
|
| 42 | - protected $connection; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @param \OCP\IConfig $config |
|
| 46 | - * @param \OCP\IDBConnection $connection |
|
| 47 | - */ |
|
| 48 | - public function __construct($config, $connection) { |
|
| 49 | - $this->connection = $connection; |
|
| 50 | - $this->config = $config; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - public function getName() { |
|
| 54 | - return 'Repair invalid shares'; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Adjust file share permissions |
|
| 59 | - * @suppress SqlInjectionChecker |
|
| 60 | - */ |
|
| 61 | - private function adjustFileSharePermissions(IOutput $out) { |
|
| 62 | - $mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE; |
|
| 63 | - $builder = $this->connection->getQueryBuilder(); |
|
| 64 | - |
|
| 65 | - $permsFunc = $builder->expr()->bitwiseAnd('permissions', $mask); |
|
| 66 | - $builder |
|
| 67 | - ->update('share') |
|
| 68 | - ->set('permissions', $permsFunc) |
|
| 69 | - ->where($builder->expr()->eq('item_type', $builder->expr()->literal('file'))) |
|
| 70 | - ->andWhere($builder->expr()->neq('permissions', $permsFunc)); |
|
| 71 | - |
|
| 72 | - $updatedEntries = $builder->execute(); |
|
| 73 | - if ($updatedEntries > 0) { |
|
| 74 | - $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * Remove shares where the parent share does not exist anymore |
|
| 80 | - */ |
|
| 81 | - private function removeSharesNonExistingParent(IOutput $out) { |
|
| 82 | - $deletedEntries = 0; |
|
| 83 | - |
|
| 84 | - $query = $this->connection->getQueryBuilder(); |
|
| 85 | - $query->select('s1.parent') |
|
| 86 | - ->from('share', 's1') |
|
| 87 | - ->where($query->expr()->isNotNull('s1.parent')) |
|
| 88 | - ->andWhere($query->expr()->isNull('s2.id')) |
|
| 89 | - ->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id')) |
|
| 90 | - ->groupBy('s1.parent') |
|
| 91 | - ->setMaxResults(self::CHUNK_SIZE); |
|
| 92 | - |
|
| 93 | - $deleteQuery = $this->connection->getQueryBuilder(); |
|
| 94 | - $deleteQuery->delete('share') |
|
| 95 | - ->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent'))); |
|
| 96 | - |
|
| 97 | - $deletedInLastChunk = self::CHUNK_SIZE; |
|
| 98 | - while ($deletedInLastChunk === self::CHUNK_SIZE) { |
|
| 99 | - $deletedInLastChunk = 0; |
|
| 100 | - $result = $query->execute(); |
|
| 101 | - while ($row = $result->fetch()) { |
|
| 102 | - $deletedInLastChunk++; |
|
| 103 | - $deletedEntries += $deleteQuery->setParameter('parent', (int) $row['parent']) |
|
| 104 | - ->execute(); |
|
| 105 | - } |
|
| 106 | - $result->closeCursor(); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - if ($deletedEntries) { |
|
| 110 | - $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - public function run(IOutput $out) { |
|
| 115 | - $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
|
| 116 | - if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) { |
|
| 117 | - $this->adjustFileSharePermissions($out); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - $this->removeSharesNonExistingParent($out); |
|
| 121 | - } |
|
| 36 | + const CHUNK_SIZE = 200; |
|
| 37 | + |
|
| 38 | + /** @var \OCP\IConfig */ |
|
| 39 | + protected $config; |
|
| 40 | + |
|
| 41 | + /** @var \OCP\IDBConnection */ |
|
| 42 | + protected $connection; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @param \OCP\IConfig $config |
|
| 46 | + * @param \OCP\IDBConnection $connection |
|
| 47 | + */ |
|
| 48 | + public function __construct($config, $connection) { |
|
| 49 | + $this->connection = $connection; |
|
| 50 | + $this->config = $config; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + public function getName() { |
|
| 54 | + return 'Repair invalid shares'; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Adjust file share permissions |
|
| 59 | + * @suppress SqlInjectionChecker |
|
| 60 | + */ |
|
| 61 | + private function adjustFileSharePermissions(IOutput $out) { |
|
| 62 | + $mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE; |
|
| 63 | + $builder = $this->connection->getQueryBuilder(); |
|
| 64 | + |
|
| 65 | + $permsFunc = $builder->expr()->bitwiseAnd('permissions', $mask); |
|
| 66 | + $builder |
|
| 67 | + ->update('share') |
|
| 68 | + ->set('permissions', $permsFunc) |
|
| 69 | + ->where($builder->expr()->eq('item_type', $builder->expr()->literal('file'))) |
|
| 70 | + ->andWhere($builder->expr()->neq('permissions', $permsFunc)); |
|
| 71 | + |
|
| 72 | + $updatedEntries = $builder->execute(); |
|
| 73 | + if ($updatedEntries > 0) { |
|
| 74 | + $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * Remove shares where the parent share does not exist anymore |
|
| 80 | + */ |
|
| 81 | + private function removeSharesNonExistingParent(IOutput $out) { |
|
| 82 | + $deletedEntries = 0; |
|
| 83 | + |
|
| 84 | + $query = $this->connection->getQueryBuilder(); |
|
| 85 | + $query->select('s1.parent') |
|
| 86 | + ->from('share', 's1') |
|
| 87 | + ->where($query->expr()->isNotNull('s1.parent')) |
|
| 88 | + ->andWhere($query->expr()->isNull('s2.id')) |
|
| 89 | + ->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id')) |
|
| 90 | + ->groupBy('s1.parent') |
|
| 91 | + ->setMaxResults(self::CHUNK_SIZE); |
|
| 92 | + |
|
| 93 | + $deleteQuery = $this->connection->getQueryBuilder(); |
|
| 94 | + $deleteQuery->delete('share') |
|
| 95 | + ->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent'))); |
|
| 96 | + |
|
| 97 | + $deletedInLastChunk = self::CHUNK_SIZE; |
|
| 98 | + while ($deletedInLastChunk === self::CHUNK_SIZE) { |
|
| 99 | + $deletedInLastChunk = 0; |
|
| 100 | + $result = $query->execute(); |
|
| 101 | + while ($row = $result->fetch()) { |
|
| 102 | + $deletedInLastChunk++; |
|
| 103 | + $deletedEntries += $deleteQuery->setParameter('parent', (int) $row['parent']) |
|
| 104 | + ->execute(); |
|
| 105 | + } |
|
| 106 | + $result->closeCursor(); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + if ($deletedEntries) { |
|
| 110 | + $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + public function run(IOutput $out) { |
|
| 115 | + $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
|
| 116 | + if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) { |
|
| 117 | + $this->adjustFileSharePermissions($out); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + $this->removeSharesNonExistingParent($out); |
|
| 121 | + } |
|
| 122 | 122 | } |