mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
Merge pull request #52694 from nextcloud/fixHardcodedVersionsFolder
fix(files_versions): Folder should not be hardcoded
This commit is contained in:
commit
b67a43764a
1 changed files with 8 additions and 4 deletions
|
|
@ -367,16 +367,20 @@ class LegacyVersionsBackend implements IVersionBackend, IDeletableVersionBackend
|
|||
* @inheritdoc
|
||||
*/
|
||||
public function clearVersionsForFile(IUser $user, Node $source, Node $target): void {
|
||||
$userFolder = $this->rootFolder->getUserFolder($user->getUID());
|
||||
$userId = $user->getUID();
|
||||
$userFolder = $this->rootFolder->getUserFolder($userId);
|
||||
|
||||
$relativePath = $userFolder->getRelativePath($source->getPath());
|
||||
if ($relativePath === null) {
|
||||
throw new Exception('Relative path not found for node with path: ' . $source->getPath());
|
||||
}
|
||||
|
||||
$versions = Storage::getVersions($user->getUID(), $relativePath);
|
||||
/** @var Folder versionFolder */
|
||||
$versionFolder = $this->rootFolder->get('admin/files_versions');
|
||||
$versionFolder = $this->rootFolder->get($userId . '/files_versions');
|
||||
if (!$versionFolder instanceof Folder) {
|
||||
throw new Exception('User versions folder does not exist');
|
||||
}
|
||||
|
||||
$versions = Storage::getVersions($userId, $relativePath);
|
||||
foreach ($versions as $version) {
|
||||
$versionFolder->get($version['path'] . '.v' . (int)$version['version'])->delete();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue