diff --git a/lib/Command/Index.php b/lib/Command/Index.php index 379b29e0..9c8f8e45 100644 --- a/lib/Command/Index.php +++ b/lib/Command/Index.php @@ -109,10 +109,10 @@ class Index extends Command { \OC_Util::setupFS($user->getUID()); $userFolder = $this->rootFolder->getUserFolder($user->getUID()); - $this->parseFolder($user, $userFolder); + $this->parseFolder($userFolder); } - private function parseFolder(IUser $user, Folder $folder): void { + private function parseFolder(Folder $folder): void { try { $folderPath = $folder->getPath(); @@ -129,9 +129,9 @@ class Index extends Command { foreach ($nodes as $node) { if ($node instanceof Folder) { - $this->parseFolder($user, $node); + $this->parseFolder($node); } elseif ($node instanceof File) { - $this->parseFile($user, $node); + $this->parseFile($node); } } } catch (StorageNotAvailableException $e) { @@ -142,8 +142,8 @@ class Index extends Command { } } - private function parseFile(IUser $user, File $file): void { + private function parseFile(File $file): void { // $this->output->writeln('Generating entry for ' . $file->getPath() . ' ' . $file->getId()); - $this->util->processFile($user->getUID(), $file); + $this->util->processFile($file); } } \ No newline at end of file diff --git a/lib/Db/Util.php b/lib/Db/Util.php index 25fa5ed8..5050c628 100644 --- a/lib/Db/Util.php +++ b/lib/Db/Util.php @@ -42,7 +42,7 @@ class Util { return $dateTaken; } - public function processFile(string $user, File $file): void { + public function processFile(File $file): void { $mime = $file->getMimeType(); $is_image = in_array($mime, Application::IMAGE_MIMES); $is_video = in_array($mime, Application::VIDEO_MIMES); @@ -51,6 +51,7 @@ class Util { } // Get parameters + $user = $file->getOwner()->getUID(); $fileId = $file->getId(); $dateTaken = $this->getDateTaken($file); $dayId = floor($dateTaken / 86400); diff --git a/lib/Listeners/PostWriteListener.php b/lib/Listeners/PostWriteListener.php index 2e4c36ac..ab149013 100644 --- a/lib/Listeners/PostWriteListener.php +++ b/lib/Listeners/PostWriteListener.php @@ -47,13 +47,10 @@ class PostWriteListener implements IEventListener { } $node = $event->getNode(); - $absPath = ltrim($node->getPath(), '/'); - $owner = explode('/', $absPath)[0]; - - if ($node instanceof Folder || !$this->userManager->userExists($owner)) { + if ($node instanceof Folder) { return; } - $this->util->processFile($owner, $node); + $this->util->processFile($node); } } \ No newline at end of file