Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix hookconnector tests
Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed Jan 26, 2023
commit d8b479752d327f8901a84454c17fd3c6f701a98d
35 changes: 5 additions & 30 deletions apps/files_versions/lib/Listener/FileEventsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,7 @@ public function write_hook(Node $node): void {
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);

Expand Down Expand Up @@ -177,12 +172,7 @@ public function remove_hook(Node $node): void {
* 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;
Expand All @@ -195,12 +185,7 @@ public function pre_remove_hook(Node $node): void {
* 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');
Expand All @@ -213,12 +198,7 @@ public function rename_hook(Node $source, Node $target): void {
* 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');
Expand All @@ -234,12 +214,7 @@ public function copy_hook(Node $source, Node $target): void {
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);
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/Files/Node/HookConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ protected function setUp(): void {
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(),
Expand Down