Skip to content

Commit b2cc661

Browse files
committed
Cleanup versions entity in during versions:clean command
Signed-off-by: Louis Chemineau <[email protected]>
1 parent 937a6a8 commit b2cc661

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

apps/files_versions/lib/Command/CleanUp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ protected function deleteVersions(string $user, ?string $path = null): void {
122122
\OC_Util::setupFS($user);
123123

124124
$fullPath = '/' . $user . '/files_versions' . ($path ? '/' . $path : '');
125-
$this->versionMapper->deleteAllVersionsForUser($user);
125+
$this->versionMapper->deleteAllVersionsForUser($user, $path);
126126
if ($this->rootFolder->nodeExists($fullPath)) {
127127
$this->rootFolder->get($fullPath)->delete();
128128
}

apps/files_versions/lib/Db/VersionsMapper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ public function deleteAllVersionsForFileId(int $fileId): int {
8585
->executeStatement();
8686
}
8787

88-
public function deleteAllVersionsForUser(string $userId): int {
88+
public function deleteAllVersionsForUser(string $userId, string $path = null): int {
8989
$deleteQuery = $this->db->getQueryBuilder();
9090
$filesVersionSelect = $this->db->getQueryBuilder();
9191
$filesVersionSelect->select('fileid')
9292
->from('filecache', 'f')
9393
->join('f', 'mounts', 'm', $filesVersionSelect->expr()->eq('f.storage', 'm.storage_id'))
94-
->where($filesVersionSelect->expr()->like('f.path', $deleteQuery->createNamedParameter('files/%', IQueryBuilder::PARAM_STR)))
94+
->where($filesVersionSelect->expr()->like('f.path', $deleteQuery->createNamedParameter('files'.($path ? '/' . $path : '').'/%', IQueryBuilder::PARAM_STR)))
9595
->andWhere($filesVersionSelect->expr()->eq('m.user_id', $deleteQuery->createNamedParameter($userId, IQueryBuilder::PARAM_STR)))
9696
->andWhere($filesVersionSelect->expr()->eq('m.mount_point', $deleteQuery->createNamedParameter("/$userId/", IQueryBuilder::PARAM_STR)));
9797

0 commit comments

Comments
 (0)