Fix shared folder upload

pull/37/head
Varun Patil 2022-08-16 02:33:15 +00:00
parent d50f494f72
commit 83e6247716
3 changed files with 10 additions and 12 deletions

View File

@ -109,10 +109,10 @@ class Index extends Command {
\OC_Util::setupFS($user->getUID()); \OC_Util::setupFS($user->getUID());
$userFolder = $this->rootFolder->getUserFolder($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 { try {
$folderPath = $folder->getPath(); $folderPath = $folder->getPath();
@ -129,9 +129,9 @@ class Index extends Command {
foreach ($nodes as $node) { foreach ($nodes as $node) {
if ($node instanceof Folder) { if ($node instanceof Folder) {
$this->parseFolder($user, $node); $this->parseFolder($node);
} elseif ($node instanceof File) { } elseif ($node instanceof File) {
$this->parseFile($user, $node); $this->parseFile($node);
} }
} }
} catch (StorageNotAvailableException $e) { } 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->output->writeln('Generating entry for ' . $file->getPath() . ' ' . $file->getId());
$this->util->processFile($user->getUID(), $file); $this->util->processFile($file);
} }
} }

View File

@ -42,7 +42,7 @@ class Util {
return $dateTaken; return $dateTaken;
} }
public function processFile(string $user, File $file): void { public function processFile(File $file): void {
$mime = $file->getMimeType(); $mime = $file->getMimeType();
$is_image = in_array($mime, Application::IMAGE_MIMES); $is_image = in_array($mime, Application::IMAGE_MIMES);
$is_video = in_array($mime, Application::VIDEO_MIMES); $is_video = in_array($mime, Application::VIDEO_MIMES);
@ -51,6 +51,7 @@ class Util {
} }
// Get parameters // Get parameters
$user = $file->getOwner()->getUID();
$fileId = $file->getId(); $fileId = $file->getId();
$dateTaken = $this->getDateTaken($file); $dateTaken = $this->getDateTaken($file);
$dayId = floor($dateTaken / 86400); $dayId = floor($dateTaken / 86400);

View File

@ -47,13 +47,10 @@ class PostWriteListener implements IEventListener {
} }
$node = $event->getNode(); $node = $event->getNode();
$absPath = ltrim($node->getPath(), '/'); if ($node instanceof Folder) {
$owner = explode('/', $absPath)[0];
if ($node instanceof Folder || !$this->userManager->userExists($owner)) {
return; return;
} }
$this->util->processFile($owner, $node); $this->util->processFile($node);
} }
} }