diff options
author | Louis Chemineau <louis@chmn.me> | 2022-12-08 16:40:10 +0100 |
---|---|---|
committer | Louis (Rebase PR Action) <artonge@users.noreply.github.com> | 2023-01-26 10:12:23 +0000 |
commit | 6dcfb29cfc83cbec2e3d990088c88321b5572cab (patch) | |
tree | 831b09d4f8e56e0ba9aa8c06e1c4d86091e508d8 /apps/files_versions | |
parent | c88328e68e50341fa3e22181ffb9b25ae7071ed7 (diff) | |
download | nextcloud-server-6dcfb29cfc83cbec2e3d990088c88321b5572cab.tar.gz nextcloud-server-6dcfb29cfc83cbec2e3d990088c88321b5572cab.zip |
Fix renaming files_versions
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'apps/files_versions')
-rw-r--r-- | apps/files_versions/lib/Listener/FileEventsListener.php | 13 | ||||
-rw-r--r-- | apps/files_versions/tests/StorageTest.php | 4 | ||||
-rw-r--r-- | apps/files_versions/tests/VersioningTest.php | 2 |
3 files changed, 8 insertions, 11 deletions
diff --git a/apps/files_versions/lib/Listener/FileEventsListener.php b/apps/files_versions/lib/Listener/FileEventsListener.php index 6cc4b0d9dcc..b3694459ac6 100644 --- a/apps/files_versions/lib/Listener/FileEventsListener.php +++ b/apps/files_versions/lib/Listener/FileEventsListener.php @@ -33,7 +33,6 @@ namespace OCA\Files_Versions\Listener; use OC\Files\Filesystem; use OC\Files\Mount\MoveableMount; use OC\Files\Node\NonExistingFile; -use OC\Files\Node\NonExistingFolder; use OC\Files\View; use OCA\Files_Versions\Db\VersionEntity; use OCA\Files_Versions\Db\VersionsMapper; @@ -183,7 +182,7 @@ class FileEventsListener implements IEventListener { return; } - $userFolder = $this->rootFolder->getUserFolder($node->getOwner()->getUID()); + $userFolder = $this->rootFolder->getUserFolder(\OC_User::getUser()); $path = $userFolder->getRelativePath($node->getPath()); $result = Storage::store($path); @@ -244,7 +243,7 @@ class FileEventsListener implements IEventListener { return; } $node = $this->versionsDeleted[$path]; - $userFolder = $this->rootFolder->getUserFolder($node->getOwner()->getUID()); + $userFolder = $this->rootFolder->getUserFolder(\OC_User::getUser()); $relativePath = $userFolder->getRelativePath($node->getPath()); unset($this->versionsDeleted[$path]); Storage::delete($relativePath); @@ -255,7 +254,7 @@ class FileEventsListener implements IEventListener { * mark file as "deleted" so that we can clean up the versions if the file is gone */ public function pre_remove_hook(Node $node): void { - $userFolder = $this->rootFolder->getUserFolder($node->getOwner()->getUID()); + $userFolder = $this->rootFolder->getUserFolder(\OC_User::getUser()); $path = $userFolder->getRelativePath($node->getPath()); Storage::markDeletedFile($path); $this->versionsDeleted[$node->getPath()] = $node; @@ -268,7 +267,7 @@ class FileEventsListener implements IEventListener { * of the stored versions along the actual file */ public function rename_hook(Node $source, Node $target): void { - $userFolder = $this->rootFolder->getUserFolder($target->getOwner()->getUID()); + $userFolder = $this->rootFolder->getUserFolder(\OC_User::getUser()); $oldPath = $userFolder->getRelativePath($source->getPath()); $newPath = $userFolder->getRelativePath($target->getPath()); Storage::renameOrCopy($oldPath, $newPath, 'rename'); @@ -281,7 +280,7 @@ class FileEventsListener implements IEventListener { * the stored versions to the new location */ public function copy_hook(Node $source, Node $target): void { - $userFolder = $this->rootFolder->getUserFolder($target->getOwner()->getUID()); + $userFolder = $this->rootFolder->getUserFolder(\OC_User::getUser()); $oldPath = $userFolder->getRelativePath($source->getPath()); $newPath = $userFolder->getRelativePath($target->getPath()); Storage::renameOrCopy($oldPath, $newPath, 'copy'); @@ -297,7 +296,7 @@ class FileEventsListener implements IEventListener { public function pre_renameOrCopy_hook(Node $source, Node $target): void { // if we rename a movable mount point, then the versions don't have // to be renamed - $userFolder = $this->rootFolder->getUserFolder($source->getOwner()->getUID()); + $userFolder = $this->rootFolder->getUserFolder(\OC_User::getUser()); $oldPath = $userFolder->getRelativePath($source->getPath()); $newPath = $userFolder->getRelativePath($target->getPath()); $absOldPath = Filesystem::normalizePath('/' . \OC_User::getUser() . '/files' . $oldPath); diff --git a/apps/files_versions/tests/StorageTest.php b/apps/files_versions/tests/StorageTest.php index c355776451a..b319cc2c9c7 100644 --- a/apps/files_versions/tests/StorageTest.php +++ b/apps/files_versions/tests/StorageTest.php @@ -44,8 +44,6 @@ class StorageTest extends TestCase { protected function setUp(): void { parent::setUp(); - \OC::$server->boot(); - $expiration = $this->createMock(Expiration::class); $expiration->method('getMaxAgeAsTimestamp') ->willReturnCallback(function () { @@ -53,7 +51,7 @@ class StorageTest extends TestCase { }); $this->overwriteService(Expiration::class, $expiration); - // Hooks::connectHooks(); + \OC::$server->boot(); $this->createUser('version_test', ''); $this->loginAsUser('version_test'); diff --git a/apps/files_versions/tests/VersioningTest.php b/apps/files_versions/tests/VersioningTest.php index 15173dac902..95498c9f2db 100644 --- a/apps/files_versions/tests/VersioningTest.php +++ b/apps/files_versions/tests/VersioningTest.php @@ -100,7 +100,7 @@ class VersioningTest extends \Test\TestCase { // clear hooks \OC_Hook::clear(); \OC::registerShareHooks(\OC::$server->getSystemConfig()); - // \OCA\Files_Versions\Hooks::connectHooks(); + \OC::$server->boot(); self::loginHelper(self::TEST_VERSIONS_USER); $this->rootView = new \OC\Files\View(); |