Fix hookconnector tests

Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
Louis Chemineau 2022-12-07 15:55:36 +01:00 committed by Louis (Rebase PR Action)
parent 53d736207c
commit d8b479752d
2 changed files with 7 additions and 31 deletions

View file

@ -118,12 +118,7 @@ class FileEventsListener implements IEventListener {
return;
}
$owner = $node->getOwner();
// if ($owner === null) {
// return;
// }
$userFolder = $this->rootFolder->getUserFolder($owner->getUID());
$userFolder = $this->rootFolder->getUserFolder($node->getOwner()->getUID());
$path = $userFolder->getRelativePath($node->getPath());
$result = Storage::store($path);
@ -177,12 +172,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 {
$owner = $node->getOwner();
// if ($owner === null) {
// return;
// }
$userFolder = $this->rootFolder->getUserFolder($owner->getUID());
$userFolder = $this->rootFolder->getUserFolder($node->getOwner()->getUID());
$path = $userFolder->getRelativePath($node->getPath());
Storage::markDeletedFile($path);
$this->versionsDeleted[$node->getPath()] = $node;
@ -195,12 +185,7 @@ class FileEventsListener implements IEventListener {
* of the stored versions along the actual file
*/
public function rename_hook(Node $source, Node $target): void {
$owner = $target->getOwner();
// if ($owner === null) {
// return;
// }
$userFolder = $this->rootFolder->getUserFolder($owner->getUID());
$userFolder = $this->rootFolder->getUserFolder($target->getOwner()->getUID());
$oldPath = $userFolder->getRelativePath($source->getPath());
$newPath = $userFolder->getRelativePath($target->getPath());
Storage::renameOrCopy($oldPath, $newPath, 'rename');
@ -213,12 +198,7 @@ class FileEventsListener implements IEventListener {
* the stored versions to the new location
*/
public function copy_hook(Node $source, Node $target): void {
$owner = $target->getOwner();
// if ($owner === null) {
// return;
// }
$userFolder = $this->rootFolder->getUserFolder($owner->getUID());
$userFolder = $this->rootFolder->getUserFolder($target->getOwner()->getUID());
$oldPath = $userFolder->getRelativePath($source->getPath());
$newPath = $userFolder->getRelativePath($target->getPath());
Storage::renameOrCopy($oldPath, $newPath, 'copy');
@ -234,12 +214,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
$owner = $source->getOwner();
// if ($owner === null) {
// return;
// }
$userFolder = $this->rootFolder->getUserFolder($owner->getUID());
$userFolder = $this->rootFolder->getUserFolder($source->getOwner()->getUID());
$oldPath = $userFolder->getRelativePath($source->getPath());
$newPath = $userFolder->getRelativePath($target->getPath());
$absOldPath = Filesystem::normalizePath('/' . \OC_User::getUser() . '/files' . $oldPath);

View file

@ -69,8 +69,9 @@ class HookConnectorTest extends TestCase {
parent::setUp();
$this->userId = $this->getUniqueID();
$this->createUser($this->userId, 'pass');
// this will setup the FS
$this->loginAsUser($this->userId);
$this->registerMount($this->userId, new Temporary(), '/' . $this->userId . '/files/');
\OC_Util::setupFS($this->userId);
$this->view = new View();
$this->root = new Root(
Filesystem::getMountManager(),