@@ -29,15 +29,15 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | interface ILinkAction extends IAction { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @since 12.0 |
|
| 34 | - * @param string $href the target URL of the action |
|
| 35 | - */ |
|
| 36 | - public function setHref($href); |
|
| 32 | + /** |
|
| 33 | + * @since 12.0 |
|
| 34 | + * @param string $href the target URL of the action |
|
| 35 | + */ |
|
| 36 | + public function setHref($href); |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @since 12.0 |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - public function getHref(); |
|
| 38 | + /** |
|
| 39 | + * @since 12.0 |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + public function getHref(); |
|
| 43 | 43 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | use OC\DB\QueryBuilder\QueryFunction; |
| 25 | 25 | |
| 26 | 26 | class OCIFunctionBuilder extends FunctionBuilder { |
| 27 | - public function md5($input) { |
|
| 28 | - return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw(' . $this->helper->quoteColumnName($input) .')))'); |
|
| 29 | - } |
|
| 27 | + public function md5($input) { |
|
| 28 | + return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw(' . $this->helper->quoteColumnName($input) .')))'); |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | |
| 26 | 26 | class OCIFunctionBuilder extends FunctionBuilder { |
| 27 | 27 | public function md5($input) { |
| 28 | - return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw(' . $this->helper->quoteColumnName($input) .')))'); |
|
| 28 | + return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw('.$this->helper->quoteColumnName($input).')))'); |
|
| 29 | 29 | } |
| 30 | 30 | } |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function fixupStatement($statement) { |
| 44 | 44 | $statement = preg_replace('/`(\w+)` ILIKE \?/', 'LOWER($1) LIKE LOWER(?)', $statement); |
| 45 | - $statement = str_replace( '`', '"', $statement ); |
|
| 46 | - $statement = str_ireplace( 'NOW()', 'datetime(\'now\')', $statement ); |
|
| 45 | + $statement = str_replace('`', '"', $statement); |
|
| 46 | + $statement = str_ireplace('NOW()', 'datetime(\'now\')', $statement); |
|
| 47 | 47 | $statement = str_ireplace('GREATEST(', 'MAX(', $statement); |
| 48 | - $statement = str_ireplace( 'UNIX_TIMESTAMP()', 'strftime(\'%s\',\'now\')', $statement ); |
|
| 48 | + $statement = str_ireplace('UNIX_TIMESTAMP()', 'strftime(\'%s\',\'now\')', $statement); |
|
| 49 | 49 | return $statement; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | if (empty($compare)) { |
| 65 | 65 | $compare = array_keys($input); |
| 66 | 66 | } |
| 67 | - $fieldList = '`' . implode('`,`', array_keys($input)) . '`'; |
|
| 67 | + $fieldList = '`'.implode('`,`', array_keys($input)).'`'; |
|
| 68 | 68 | $query = "INSERT INTO `$table` ($fieldList) SELECT " |
| 69 | - . str_repeat('?,', count($input)-1).'? ' |
|
| 69 | + . str_repeat('?,', count($input) - 1).'? ' |
|
| 70 | 70 | . " WHERE NOT EXISTS (SELECT 1 FROM `$table` WHERE "; |
| 71 | 71 | |
| 72 | 72 | $inserts = array_values($input); |
| 73 | - foreach($compare as $key) { |
|
| 74 | - $query .= '`' . $key . '`'; |
|
| 73 | + foreach ($compare as $key) { |
|
| 74 | + $query .= '`'.$key.'`'; |
|
| 75 | 75 | if (is_null($input[$key])) { |
| 76 | 76 | $query .= ' IS NULL AND '; |
| 77 | 77 | } else { |
@@ -31,70 +31,70 @@ |
||
| 31 | 31 | |
| 32 | 32 | class AdapterSqlite extends Adapter { |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @param string $tableName |
|
| 36 | - */ |
|
| 37 | - public function lockTable($tableName) { |
|
| 38 | - $this->conn->executeUpdate('BEGIN EXCLUSIVE TRANSACTION'); |
|
| 39 | - } |
|
| 34 | + /** |
|
| 35 | + * @param string $tableName |
|
| 36 | + */ |
|
| 37 | + public function lockTable($tableName) { |
|
| 38 | + $this->conn->executeUpdate('BEGIN EXCLUSIVE TRANSACTION'); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function unlockTable() { |
|
| 42 | - $this->conn->executeUpdate('COMMIT TRANSACTION'); |
|
| 43 | - } |
|
| 41 | + public function unlockTable() { |
|
| 42 | + $this->conn->executeUpdate('COMMIT TRANSACTION'); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function fixupStatement($statement) { |
|
| 46 | - $statement = preg_replace('/`(\w+)` ILIKE \?/', 'LOWER($1) LIKE LOWER(?)', $statement); |
|
| 47 | - $statement = str_replace( '`', '"', $statement ); |
|
| 48 | - $statement = str_ireplace( 'NOW()', 'datetime(\'now\')', $statement ); |
|
| 49 | - $statement = str_ireplace('GREATEST(', 'MAX(', $statement); |
|
| 50 | - $statement = str_ireplace( 'UNIX_TIMESTAMP()', 'strftime(\'%s\',\'now\')', $statement ); |
|
| 51 | - return $statement; |
|
| 52 | - } |
|
| 45 | + public function fixupStatement($statement) { |
|
| 46 | + $statement = preg_replace('/`(\w+)` ILIKE \?/', 'LOWER($1) LIKE LOWER(?)', $statement); |
|
| 47 | + $statement = str_replace( '`', '"', $statement ); |
|
| 48 | + $statement = str_ireplace( 'NOW()', 'datetime(\'now\')', $statement ); |
|
| 49 | + $statement = str_ireplace('GREATEST(', 'MAX(', $statement); |
|
| 50 | + $statement = str_ireplace( 'UNIX_TIMESTAMP()', 'strftime(\'%s\',\'now\')', $statement ); |
|
| 51 | + return $statement; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Insert a row if the matching row does not exists. To accomplish proper race condition avoidance |
|
| 56 | - * it is needed that there is also a unique constraint on the values. Then this method will |
|
| 57 | - * catch the exception and return 0. |
|
| 58 | - * |
|
| 59 | - * @param string $table The table name (will replace *PREFIX* with the actual prefix) |
|
| 60 | - * @param array $input data that should be inserted into the table (column name => value) |
|
| 61 | - * @param array|null $compare List of values that should be checked for "if not exists" |
|
| 62 | - * If this is null or an empty array, all keys of $input will be compared |
|
| 63 | - * Please note: text fields (clob) must not be used in the compare array |
|
| 64 | - * @return int number of inserted rows |
|
| 65 | - * @throws \Doctrine\DBAL\DBALException |
|
| 66 | - * @deprecated 15.0.0 - use unique index and "try { $db->insert() } catch (UniqueConstraintViolationException $e) {}" instead, because it is more reliable and does not have the risk for deadlocks - see https://github.com/nextcloud/server/pull/12371 |
|
| 67 | - */ |
|
| 68 | - public function insertIfNotExist($table, $input, array $compare = null) { |
|
| 69 | - if (empty($compare)) { |
|
| 70 | - $compare = array_keys($input); |
|
| 71 | - } |
|
| 72 | - $fieldList = '`' . implode('`,`', array_keys($input)) . '`'; |
|
| 73 | - $query = "INSERT INTO `$table` ($fieldList) SELECT " |
|
| 74 | - . str_repeat('?,', count($input)-1).'? ' |
|
| 75 | - . " WHERE NOT EXISTS (SELECT 1 FROM `$table` WHERE "; |
|
| 54 | + /** |
|
| 55 | + * Insert a row if the matching row does not exists. To accomplish proper race condition avoidance |
|
| 56 | + * it is needed that there is also a unique constraint on the values. Then this method will |
|
| 57 | + * catch the exception and return 0. |
|
| 58 | + * |
|
| 59 | + * @param string $table The table name (will replace *PREFIX* with the actual prefix) |
|
| 60 | + * @param array $input data that should be inserted into the table (column name => value) |
|
| 61 | + * @param array|null $compare List of values that should be checked for "if not exists" |
|
| 62 | + * If this is null or an empty array, all keys of $input will be compared |
|
| 63 | + * Please note: text fields (clob) must not be used in the compare array |
|
| 64 | + * @return int number of inserted rows |
|
| 65 | + * @throws \Doctrine\DBAL\DBALException |
|
| 66 | + * @deprecated 15.0.0 - use unique index and "try { $db->insert() } catch (UniqueConstraintViolationException $e) {}" instead, because it is more reliable and does not have the risk for deadlocks - see https://github.com/nextcloud/server/pull/12371 |
|
| 67 | + */ |
|
| 68 | + public function insertIfNotExist($table, $input, array $compare = null) { |
|
| 69 | + if (empty($compare)) { |
|
| 70 | + $compare = array_keys($input); |
|
| 71 | + } |
|
| 72 | + $fieldList = '`' . implode('`,`', array_keys($input)) . '`'; |
|
| 73 | + $query = "INSERT INTO `$table` ($fieldList) SELECT " |
|
| 74 | + . str_repeat('?,', count($input)-1).'? ' |
|
| 75 | + . " WHERE NOT EXISTS (SELECT 1 FROM `$table` WHERE "; |
|
| 76 | 76 | |
| 77 | - $inserts = array_values($input); |
|
| 78 | - foreach($compare as $key) { |
|
| 79 | - $query .= '`' . $key . '`'; |
|
| 80 | - if (is_null($input[$key])) { |
|
| 81 | - $query .= ' IS NULL AND '; |
|
| 82 | - } else { |
|
| 83 | - $inserts[] = $input[$key]; |
|
| 84 | - $query .= ' = ? AND '; |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - $query = substr($query, 0, -5); |
|
| 88 | - $query .= ')'; |
|
| 77 | + $inserts = array_values($input); |
|
| 78 | + foreach($compare as $key) { |
|
| 79 | + $query .= '`' . $key . '`'; |
|
| 80 | + if (is_null($input[$key])) { |
|
| 81 | + $query .= ' IS NULL AND '; |
|
| 82 | + } else { |
|
| 83 | + $inserts[] = $input[$key]; |
|
| 84 | + $query .= ' = ? AND '; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + $query = substr($query, 0, -5); |
|
| 88 | + $query .= ')'; |
|
| 89 | 89 | |
| 90 | - try { |
|
| 91 | - return $this->conn->executeUpdate($query, $inserts); |
|
| 92 | - } catch (UniqueConstraintViolationException $e) { |
|
| 93 | - // if this is thrown then a concurrent insert happened between the insert and the sub-select in the insert, that should have avoided it |
|
| 94 | - // it's fine to ignore this then |
|
| 95 | - // |
|
| 96 | - // more discussions about this can be found at https://github.com/nextcloud/server/pull/12315 |
|
| 97 | - return 0; |
|
| 98 | - } |
|
| 99 | - } |
|
| 90 | + try { |
|
| 91 | + return $this->conn->executeUpdate($query, $inserts); |
|
| 92 | + } catch (UniqueConstraintViolationException $e) { |
|
| 93 | + // if this is thrown then a concurrent insert happened between the insert and the sub-select in the insert, that should have avoided it |
|
| 94 | + // it's fine to ignore this then |
|
| 95 | + // |
|
| 96 | + // more discussions about this can be found at https://github.com/nextcloud/server/pull/12315 |
|
| 97 | + return 0; |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | 100 | } |
@@ -25,22 +25,22 @@ |
||
| 25 | 25 | * @since 12.0.0 |
| 26 | 26 | */ |
| 27 | 27 | interface ISearchOrder { |
| 28 | - const DIRECTION_ASCENDING = 'asc'; |
|
| 29 | - const DIRECTION_DESCENDING = 'desc'; |
|
| 28 | + const DIRECTION_ASCENDING = 'asc'; |
|
| 29 | + const DIRECTION_DESCENDING = 'desc'; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * The direction to sort in, either ISearchOrder::DIRECTION_ASCENDING or ISearchOrder::DIRECTION_DESCENDING |
|
| 33 | - * |
|
| 34 | - * @return string |
|
| 35 | - * @since 12.0.0 |
|
| 36 | - */ |
|
| 37 | - public function getDirection(); |
|
| 31 | + /** |
|
| 32 | + * The direction to sort in, either ISearchOrder::DIRECTION_ASCENDING or ISearchOrder::DIRECTION_DESCENDING |
|
| 33 | + * |
|
| 34 | + * @return string |
|
| 35 | + * @since 12.0.0 |
|
| 36 | + */ |
|
| 37 | + public function getDirection(); |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * The field to sort on |
|
| 41 | - * |
|
| 42 | - * @return string |
|
| 43 | - * @since 12.0.0 |
|
| 44 | - */ |
|
| 45 | - public function getField(); |
|
| 39 | + /** |
|
| 40 | + * The field to sort on |
|
| 41 | + * |
|
| 42 | + * @return string |
|
| 43 | + * @since 12.0.0 |
|
| 44 | + */ |
|
| 45 | + public function getField(); |
|
| 46 | 46 | } |
@@ -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 | } |