aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2022-11-23 14:57:30 +0100
committerLouis (Rebase PR Action) <artonge@users.noreply.github.com>2023-01-26 10:12:23 +0000
commit1adc9d2aabeb773c291f718f508a15ecfb1c4d85 (patch)
treec72dee1adfe363febd77e5f3381386f3ed82a209 /apps
parent6a2f8bc5997a4b40baf8b967d6d8ccdf29735d3b (diff)
downloadnextcloud-server-1adc9d2aabeb773c291f718f508a15ecfb1c4d85.tar.gz
nextcloud-server-1adc9d2aabeb773c291f718f508a15ecfb1c4d85.zip
Delete file versions entries in DB when node is deleted
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_versions/lib/Db/VersionsMapper.php9
-rw-r--r--apps/files_versions/lib/Hooks.php1
2 files changed, 10 insertions, 0 deletions
diff --git a/apps/files_versions/lib/Db/VersionsMapper.php b/apps/files_versions/lib/Db/VersionsMapper.php
index 3da684b7d77..b1cf202a6ce 100644
--- a/apps/files_versions/lib/Db/VersionsMapper.php
+++ b/apps/files_versions/lib/Db/VersionsMapper.php
@@ -29,6 +29,7 @@ namespace OCA\Files_Versions\Db;
use OCA\Files_Versions\Db\VersionEntity;
use OCP\IDBConnection;
use OCP\AppFramework\Db\QBMapper;
+use OCP\DB\IResult;
/**
* @extends QBMapper<VersionEntity>
@@ -61,4 +62,12 @@ class VersionsMapper extends QBMapper {
return $this->findEntity($qb);
}
+
+ public function deleteAllVersionsForFileId(int $fileId): int {
+ $qb = $this->db->getQueryBuilder();
+
+ return $qb->delete($this->getTableName())
+ ->where($qb->expr()->eq('file_id', $qb->createNamedParameter($fileId)))
+ ->executeStatement();
+ }
}
diff --git a/apps/files_versions/lib/Hooks.php b/apps/files_versions/lib/Hooks.php
index ebb0974c4ed..ba22349e221 100644
--- a/apps/files_versions/lib/Hooks.php
+++ b/apps/files_versions/lib/Hooks.php
@@ -144,6 +144,7 @@ class Hooks implements IEventListener {
public function remove_hook(Node $node): void {
$path = $this->userFolder->getRelativePath($node->getPath());
Storage::delete($path);
+ $this->versionsMapper->deleteAllVersionsForFileId($node->getId());
}
/**