mirror of
https://github.com/nextcloud/server.git
synced 2026-03-31 06:36:18 -04:00
Merge pull request #55644 from nextcloud/backport/54793/stable32
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Integration sqlite / changes (push) Waiting to run
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, --tags ~@large files_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, capabilities_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, collaboration_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, comments_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, dav_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, federation_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, file_conversions) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, filesdrop_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, ldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, openldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, openldap_numerical_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, remoteapi_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, routing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, setup_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, sharees_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, sharing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, theming_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, videoverification_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite-summary (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis (push) Waiting to run
Psalm static code analysis / static-code-analysis-security (push) Waiting to run
Psalm static code analysis / static-code-analysis-ocp (push) Waiting to run
Psalm static code analysis / static-code-analysis-ncu (push) Waiting to run
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Integration sqlite / changes (push) Waiting to run
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, --tags ~@large files_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, capabilities_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, collaboration_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, comments_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, dav_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, federation_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, file_conversions) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, filesdrop_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, ldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, openldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, openldap_numerical_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, remoteapi_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, routing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, setup_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, sharees_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, sharing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, theming_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, videoverification_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite-summary (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis (push) Waiting to run
Psalm static code analysis / static-code-analysis-security (push) Waiting to run
Psalm static code analysis / static-code-analysis-ocp (push) Waiting to run
Psalm static code analysis / static-code-analysis-ncu (push) Waiting to run
This commit is contained in:
commit
319d4ac86c
2 changed files with 50 additions and 14 deletions
|
|
@ -114,22 +114,20 @@ class FileAccess implements IFileAccess {
|
|||
|
||||
$path = $root['path'] === '' ? '' : $root['path'] . '/';
|
||||
|
||||
$qb->selectDistinct('*')
|
||||
$qb->selectDistinct('f.*')
|
||||
->from('filecache', 'f')
|
||||
->where($qb->expr()->like('f.path', $qb->createNamedParameter($this->connection->escapeLikeParameter($path) . '%')))
|
||||
->andWhere($qb->expr()->eq('f.storage', $qb->createNamedParameter($storageId)))
|
||||
->andWhere($qb->expr()->gt('f.fileid', $qb->createNamedParameter($fileIdCursor, IQueryBuilder::PARAM_INT)));
|
||||
->andWhere($qb->expr()->gt('f.fileid', $qb->createNamedParameter($fileIdCursor, IQueryBuilder::PARAM_INT)))
|
||||
->hintShardKey('storage', $storageId);
|
||||
|
||||
if (!$endToEndEncrypted) {
|
||||
if (!$endToEndEncrypted && $this->connection->getShardDefinition('filecache') === null) {
|
||||
// End to end encrypted files are descendants of a folder with encrypted=1
|
||||
// Use a subquery to check the `encrypted` status of the parent folder
|
||||
$subQuery = $this->getQuery()->select('p.encrypted')
|
||||
->from('filecache', 'p')
|
||||
->andWhere($qb->expr()->eq('p.fileid', 'f.parent'))
|
||||
->getSQL();
|
||||
// We can only do this inner join if the filecache table is not sharded
|
||||
$qb->innerJoin('f', 'filecache', 'f2', $qb->expr()->eq('f2.fileid', 'f.parent'));
|
||||
|
||||
$qb->andWhere(
|
||||
$qb->expr()->eq($qb->createFunction(sprintf('(%s)', $subQuery)), $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT))
|
||||
$qb->expr()->eq('f2.encrypted', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -148,11 +146,42 @@ class FileAccess implements IFileAccess {
|
|||
$qb->orderBy('f.fileid', 'ASC');
|
||||
$files = $qb->executeQuery();
|
||||
|
||||
while (
|
||||
/** @var array */
|
||||
$row = $files->fetch()
|
||||
) {
|
||||
yield Cache::cacheEntryFromData($row, $this->mimeTypeLoader);
|
||||
if (!$endToEndEncrypted && $this->connection->getShardDefinition('filecache') !== null) {
|
||||
// End to end encrypted files are descendants of a folder with encrypted=1
|
||||
// If the filecache table is sharded we need to check with a separate query if the parent is encrypted
|
||||
$rows = [];
|
||||
do {
|
||||
while (count($rows) < 1000 && ($row = $files->fetch())) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
$parents = array_map(function ($row) {
|
||||
return $row['parent'];
|
||||
}, $rows);
|
||||
|
||||
$parentQuery = $this->getQuery();
|
||||
$parentQuery->select('fileid', 'encrypted')->from('filecache');
|
||||
$parentQuery->where($parentQuery->expr()->in('fileid', $parentQuery->createNamedParameter($parents, IQueryBuilder::PARAM_INT_ARRAY)));
|
||||
$parentQuery->hintShardKey('storage', $storageId);
|
||||
$result = $parentQuery->executeQuery();
|
||||
$parentRows = $result->fetchAll();
|
||||
$result->closeCursor();
|
||||
|
||||
$encryptedByFileId = array_column($parentRows, 'encrypted', 'fileid');
|
||||
foreach ($rows as $row) {
|
||||
if ($encryptedByFileId[$row['parent']]) {
|
||||
continue;
|
||||
}
|
||||
yield Cache::cacheEntryFromData($row, $this->mimeTypeLoader);
|
||||
}
|
||||
$rows = [];
|
||||
} while ($rows[] = $files->fetch());
|
||||
} else {
|
||||
while (
|
||||
/** @var array */
|
||||
$row = $files->fetch()
|
||||
) {
|
||||
yield Cache::cacheEntryFromData($row, $this->mimeTypeLoader);
|
||||
}
|
||||
}
|
||||
|
||||
$files->closeCursor();
|
||||
|
|
|
|||
|
|
@ -211,6 +211,7 @@ class FileAccessTest extends TestCase {
|
|||
'name' => $queryBuilder->createNamedParameter('files'),
|
||||
'mimetype' => 1,
|
||||
'encrypted' => 0,
|
||||
'size' => 1,
|
||||
])
|
||||
->executeStatement();
|
||||
|
||||
|
|
@ -224,6 +225,7 @@ class FileAccessTest extends TestCase {
|
|||
'name' => $queryBuilder->createNamedParameter('documents'),
|
||||
'mimetype' => 2,
|
||||
'encrypted' => 1,
|
||||
'size' => 1,
|
||||
])
|
||||
->executeStatement();
|
||||
|
||||
|
|
@ -237,6 +239,7 @@ class FileAccessTest extends TestCase {
|
|||
'name' => $queryBuilder->createNamedParameter('photos'),
|
||||
'mimetype' => 3,
|
||||
'encrypted' => 1,
|
||||
'size' => 1,
|
||||
])
|
||||
->executeStatement();
|
||||
|
||||
|
|
@ -250,6 +253,7 @@ class FileAccessTest extends TestCase {
|
|||
'name' => $queryBuilder->createNamedParameter('endtoendencrypted'),
|
||||
'mimetype' => 4,
|
||||
'encrypted' => 0,
|
||||
'size' => 1,
|
||||
])
|
||||
->executeStatement();
|
||||
|
||||
|
|
@ -263,6 +267,7 @@ class FileAccessTest extends TestCase {
|
|||
'name' => $queryBuilder->createNamedParameter('serversideencrypted'),
|
||||
'mimetype' => 4,
|
||||
'encrypted' => 1,
|
||||
'size' => 1,
|
||||
])
|
||||
->executeStatement();
|
||||
|
||||
|
|
@ -276,6 +281,7 @@ class FileAccessTest extends TestCase {
|
|||
'name' => $queryBuilder->createNamedParameter('storage2'),
|
||||
'mimetype' => 5,
|
||||
'encrypted' => 0,
|
||||
'size' => 1,
|
||||
])
|
||||
->executeStatement();
|
||||
|
||||
|
|
@ -289,6 +295,7 @@ class FileAccessTest extends TestCase {
|
|||
'name' => $queryBuilder->createNamedParameter('file'),
|
||||
'mimetype' => 6,
|
||||
'encrypted' => 0,
|
||||
'size' => 1,
|
||||
])
|
||||
->executeStatement();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue