mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 08:44:07 -04:00
Delete file versions entries in DB when node is deleted
Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
parent
6a2f8bc599
commit
1adc9d2aab
2 changed files with 10 additions and 0 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue