mirror of
https://github.com/nextcloud/server.git
synced 2026-05-19 08:25:56 -04:00
Merge pull request #60003 from nextcloud/backport/46583/stable29
Some checks failed
Integration sqlite / changes (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, --tags ~@large files_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, capabilities_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, collaboration_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, comments_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, dav_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, federation_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, filesdrop_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, ldap_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, openldap_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, openldap_numerical_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, remoteapi_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, setup_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, sharees_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, sharing_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, videoverification_features) (push) Has been cancelled
Integration sqlite / integration-sqlite-summary (push) Has been cancelled
Some checks failed
Integration sqlite / changes (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, --tags ~@large files_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, capabilities_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, collaboration_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, comments_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, dav_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, federation_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, filesdrop_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, ldap_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, openldap_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, openldap_numerical_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, remoteapi_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, setup_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, sharees_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, sharing_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, videoverification_features) (push) Has been cancelled
Integration sqlite / integration-sqlite-summary (push) Has been cancelled
This commit is contained in:
commit
736c0388ef
6 changed files with 50 additions and 35 deletions
|
|
@ -156,11 +156,11 @@ class Cache implements ICache {
|
|||
// normalize file
|
||||
$file = $this->normalize($file);
|
||||
|
||||
$query->whereStorageId($this->getNumericStorageId())
|
||||
->wherePath($file);
|
||||
$query->wherePath($file);
|
||||
} else { //file id
|
||||
$query->whereFileId($file);
|
||||
}
|
||||
$query->whereStorageId($this->getNumericStorageId());
|
||||
|
||||
$result = $query->execute();
|
||||
$data = $result->fetch();
|
||||
|
|
@ -238,6 +238,7 @@ class Cache implements ICache {
|
|||
$query = $this->getQueryBuilder();
|
||||
$query->selectFileCache()
|
||||
->whereParent($fileId)
|
||||
->whereStorageId($this->getNumericStorageId())
|
||||
->orderBy('name', 'ASC');
|
||||
|
||||
$metadataQuery = $query->selectMetadata();
|
||||
|
|
@ -385,6 +386,7 @@ class Cache implements ICache {
|
|||
|
||||
$query->update('filecache')
|
||||
->whereFileId($id)
|
||||
->whereStorageId($this->getNumericStorageId())
|
||||
->andWhere($query->expr()->orX(...array_map(function ($key, $value) use ($query) {
|
||||
return $query->expr()->orX(
|
||||
$query->expr()->neq($key, $query->createNamedParameter($value)),
|
||||
|
|
@ -560,6 +562,7 @@ class Cache implements ICache {
|
|||
if ($entry instanceof ICacheEntry) {
|
||||
$query = $this->getQueryBuilder();
|
||||
$query->delete('filecache')
|
||||
->whereStorageId($this->getNumericStorageId())
|
||||
->whereFileId($entry->getId());
|
||||
$query->execute();
|
||||
|
||||
|
|
@ -631,6 +634,7 @@ class Cache implements ICache {
|
|||
|
||||
$query = $this->getQueryBuilder();
|
||||
$query->delete('filecache')
|
||||
->whereStorageId($this->getNumericStorageId())
|
||||
->whereParentInParameter('parentIds');
|
||||
|
||||
// Sorting before chunking allows the db to find the entries close to each
|
||||
|
|
@ -977,6 +981,7 @@ class Cache implements ICache {
|
|||
$query = $this->getQueryBuilder();
|
||||
$query->select('size', 'unencrypted_size')
|
||||
->from('filecache')
|
||||
->whereStorageId($this->getNumericStorageId())
|
||||
->whereParent($id);
|
||||
if ($ignoreUnknown) {
|
||||
$query->andWhere($query->expr()->gte('size', $query->createNamedParameter(0)));
|
||||
|
|
|
|||
|
|
@ -210,15 +210,15 @@ class Propagator implements IPropagator {
|
|||
$query->update('filecache')
|
||||
->set('mtime', $query->func()->greatest('mtime', $query->createParameter('time')))
|
||||
->set('etag', $query->expr()->literal(uniqid()))
|
||||
->where($query->expr()->eq('storage', $query->expr()->literal($storageId, IQueryBuilder::PARAM_INT)))
|
||||
->where($query->expr()->eq('storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)))
|
||||
->andWhere($query->expr()->eq('path_hash', $query->createParameter('hash')));
|
||||
|
||||
$sizeQuery = $this->connection->getQueryBuilder();
|
||||
$sizeQuery->update('filecache')
|
||||
->set('size', $sizeQuery->func()->add('size', $sizeQuery->createParameter('size')))
|
||||
->where($query->expr()->eq('storage', $query->expr()->literal($storageId, IQueryBuilder::PARAM_INT)))
|
||||
->andWhere($query->expr()->eq('path_hash', $query->createParameter('hash')))
|
||||
->andWhere($sizeQuery->expr()->gt('size', $sizeQuery->expr()->literal(-1, IQueryBuilder::PARAM_INT)));
|
||||
->where($query->expr()->eq('storage', $sizeQuery->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)))
|
||||
->andWhere($query->expr()->eq('path_hash', $sizeQuery->createParameter('hash')))
|
||||
->andWhere($sizeQuery->expr()->gt('size', $sizeQuery->createNamedParameter(-1, IQueryBuilder::PARAM_INT)));
|
||||
|
||||
foreach ($this->batch as $item) {
|
||||
$query->setParameter('time', $item['time'], IQueryBuilder::PARAM_INT);
|
||||
|
|
|
|||
|
|
@ -133,7 +133,6 @@ class QuerySearchHelper {
|
|||
$query
|
||||
->leftJoin('file', 'vcategory_to_object', 'tagmap', $query->expr()->eq('file.fileid', 'tagmap.objid'))
|
||||
->leftJoin('tagmap', 'vcategory', 'tag', $query->expr()->andX(
|
||||
$query->expr()->eq('tagmap.type', 'tag.type'),
|
||||
$query->expr()->eq('tagmap.categoryid', 'tag.id'),
|
||||
$query->expr()->eq('tag.type', $query->createNamedParameter('files')),
|
||||
$query->expr()->eq('tag.uid', $query->createNamedParameter($user->getUID()))
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ class UserMountCache implements IUserMountCache {
|
|||
$builder = $this->connection->getQueryBuilder();
|
||||
$query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'mount_provider_class')
|
||||
->from('mounts', 'm')
|
||||
->where($builder->expr()->eq('user_id', $builder->createPositionalParameter($userUID)));
|
||||
->where($builder->expr()->eq('user_id', $builder->createNamedParameter($userUID)));
|
||||
|
||||
$result = $query->execute();
|
||||
$rows = $result->fetchAll();
|
||||
|
|
@ -285,7 +285,7 @@ class UserMountCache implements IUserMountCache {
|
|||
$builder = $this->connection->getQueryBuilder();
|
||||
$query = $builder->select('path')
|
||||
->from('filecache')
|
||||
->where($builder->expr()->eq('fileid', $builder->createPositionalParameter($info->getRootId())));
|
||||
->where($builder->expr()->eq('fileid', $builder->createNamedParameter($info->getRootId())));
|
||||
return $query->executeQuery()->fetchOne() ?: '';
|
||||
}
|
||||
|
||||
|
|
@ -299,10 +299,10 @@ class UserMountCache implements IUserMountCache {
|
|||
$query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path', 'mount_provider_class')
|
||||
->from('mounts', 'm')
|
||||
->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid'))
|
||||
->where($builder->expr()->eq('storage_id', $builder->createPositionalParameter($numericStorageId, IQueryBuilder::PARAM_INT)));
|
||||
->where($builder->expr()->eq('storage_id', $builder->createNamedParameter($numericStorageId, IQueryBuilder::PARAM_INT)));
|
||||
|
||||
if ($user) {
|
||||
$query->andWhere($builder->expr()->eq('user_id', $builder->createPositionalParameter($user)));
|
||||
$query->andWhere($builder->expr()->eq('user_id', $builder->createNamedParameter($user)));
|
||||
}
|
||||
|
||||
$result = $query->execute();
|
||||
|
|
@ -321,7 +321,7 @@ class UserMountCache implements IUserMountCache {
|
|||
$query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path', 'mount_provider_class')
|
||||
->from('mounts', 'm')
|
||||
->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid'))
|
||||
->where($builder->expr()->eq('root_id', $builder->createPositionalParameter($rootFileId, IQueryBuilder::PARAM_INT)));
|
||||
->where($builder->expr()->eq('root_id', $builder->createNamedParameter($rootFileId, IQueryBuilder::PARAM_INT)));
|
||||
|
||||
$result = $query->execute();
|
||||
$rows = $result->fetchAll();
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ class PropagatorTest extends TestCase {
|
|||
|
||||
foreach ($oldInfos as $i => $oldInfo) {
|
||||
if ($oldInfo->getPath() !== 'foo/baz') {
|
||||
$this->assertNotEquals($oldInfo->getEtag(), $newInfos[$i]->getEtag());
|
||||
$this->assertNotEquals($oldInfo->getEtag(), $newInfos[$i]->getEtag(), "etag for {$oldInfo->getPath()} not updated");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@
|
|||
|
||||
namespace Test\Files\Config;
|
||||
|
||||
use OC\DB\Exceptions\DbalException;
|
||||
use OC\DB\QueryBuilder\Literal;
|
||||
use OC\Files\Mount\MountPoint;
|
||||
use OC\Files\Storage\Storage;
|
||||
use OC\User\Manager;
|
||||
use OCP\Cache\CappedMemoryCache;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\Diagnostics\IEventLogger;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\Files\Config\ICachedMountInfo;
|
||||
|
|
@ -336,29 +338,38 @@ class UserMountCacheTest extends TestCase {
|
|||
|
||||
private function createCacheEntry($internalPath, $storageId, $size = 0) {
|
||||
$internalPath = trim($internalPath, '/');
|
||||
$inserted = $this->connection->insertIfNotExist('*PREFIX*filecache', [
|
||||
'storage' => $storageId,
|
||||
'path' => $internalPath,
|
||||
'path_hash' => md5($internalPath),
|
||||
'parent' => -1,
|
||||
'name' => basename($internalPath),
|
||||
'mimetype' => 0,
|
||||
'mimepart' => 0,
|
||||
'size' => $size,
|
||||
'storage_mtime' => 0,
|
||||
'encrypted' => 0,
|
||||
'unencrypted_size' => 0,
|
||||
'etag' => '',
|
||||
'permissions' => 31
|
||||
], ['storage', 'path_hash']);
|
||||
if ($inserted) {
|
||||
$id = (int)$this->connection->lastInsertId('*PREFIX*filecache');
|
||||
try {
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
$query->insert('filecache')
|
||||
->values([
|
||||
'storage' => $query->createNamedParameter($storageId),
|
||||
'path' => $query->createNamedParameter($internalPath),
|
||||
'path_hash' => $query->createNamedParameter(md5($internalPath)),
|
||||
'parent' => $query->createNamedParameter(-1, IQueryBuilder::PARAM_INT),
|
||||
'name' => $query->createNamedParameter(basename($internalPath)),
|
||||
'mimetype' => $query->createNamedParameter(0, IQueryBuilder::PARAM_INT),
|
||||
'mimepart' => $query->createNamedParameter(0, IQueryBuilder::PARAM_INT),
|
||||
'size' => $query->createNamedParameter($size),
|
||||
'storage_mtime' => $query->createNamedParameter(0, IQueryBuilder::PARAM_INT),
|
||||
'encrypted' => $query->createNamedParameter(0, IQueryBuilder::PARAM_INT),
|
||||
'unencrypted_size' => $query->createNamedParameter(0, IQueryBuilder::PARAM_INT),
|
||||
'etag' => $query->createNamedParameter(''),
|
||||
'permissions' => $query->createNamedParameter(31, IQueryBuilder::PARAM_INT),
|
||||
]);
|
||||
$query->executeStatement();
|
||||
$id = $query->getLastInsertId();
|
||||
$this->fileIds[] = $id;
|
||||
} else {
|
||||
$sql = 'SELECT `fileid` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path_hash` =?';
|
||||
$query = $this->connection->prepare($sql);
|
||||
$query->execute([$storageId, md5($internalPath)]);
|
||||
return (int)$query->fetchOne();
|
||||
} catch (DbalException $e) {
|
||||
if ($e->getReason() === DbalException::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
$query->select('fileid')
|
||||
->from('filecache')
|
||||
->where($query->expr()->eq('storage', $query->createNamedParameter($storageId)))
|
||||
->andWhere($query->expr()->eq('path_hash', $query->createNamedParameter(md5($internalPath))));
|
||||
$id = (int)$query->execute()->fetchColumn();
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue