Skip to content

Commit bcb4625

Browse files
authored
Merge pull request #63290 from nextcloud/backport/63251/stable34
[stable34] fix(preview): delete version metadata by preview ID
2 parents 1c4b7b8 + 37b1803 commit bcb4625

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

lib/private/Preview/Db/Preview.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
* @method string getEtag() Get the etag of the preview.
4848
* @method void setEtag(string $etag)
4949
* @method string|null getVersion() Get the version for files_versions_s3
50-
* @method void setVersionId(string $versionId)
50+
* @method string|null getVersionId() Get the ID of the version metadata row.
51+
* @method void setVersionId(string $versionId) Set the ID of the version metadata row.
5152
* @method bool|null getIs() Get the version for files_versions_s3
5253
* @method bool isEncrypted() Get whether the preview is encrypted. At the moment every preview is unencrypted.
5354
* @method void setEncrypted(bool $encrypted)

lib/private/Preview/Db/PreviewMapper.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@ public function update(Entity $entity): Entity {
8484
public function delete(Entity $entity): Entity {
8585
/** @var Preview $preview */
8686
$preview = $entity;
87-
if ($preview->getVersion() !== null && $preview->getVersion() !== '') {
87+
88+
$versionId = $preview->getVersionId();
89+
if ($versionId !== null && $versionId !== '' && $versionId !== '-1') {
8890
$qb = $this->db->getQueryBuilder();
8991
$qb->delete(self::VERSION_TABLE_NAME)
90-
->where($qb->expr()->eq('file_id', $qb->createNamedParameter($preview->getFileId())))
91-
->andWhere($qb->expr()->eq('version', $qb->createNamedParameter($preview->getVersion())))
92+
->where($qb->expr()->eq(
93+
'id',
94+
$qb->createNamedParameter($versionId),
95+
))
9296
->executeStatement();
9397
}
9498

0 commit comments

Comments
 (0)