diff options
-rw-r--r-- | lib/Events/FilesEvents.php | 19 | ||||
-rw-r--r-- | lib/Monitor.php | 9 |
2 files changed, 19 insertions, 9 deletions
diff --git a/lib/Events/FilesEvents.php b/lib/Events/FilesEvents.php index b1ba0c1..a996e61 100644 --- a/lib/Events/FilesEvents.php +++ b/lib/Events/FilesEvents.php @@ -56,7 +56,7 @@ class FilesEvents { */ public function __construct( ILogger $logger, - $monitor, + Monitor $monitor, $userId ) { @@ -72,8 +72,8 @@ class FilesEvents { * @throws NotFoundException */ public function onFileUpdate(array $params) { + $this->logger->error("Updating ".$params['path'], ['app' => Application::APP_ID]); $this->analyze([$params['path']], Monitor::WRITE); - $this->logger->error("Updating ".$params['path'], ['app' => Application::APP_ID]); } @@ -89,23 +89,28 @@ class FilesEvents { } public function onFileCreate(array $params) { - $this->logger->error("Creating ".$params['path'], ['app' => Application::APP_ID]); + $this->logger->error("Creating ".$params['path'], ['app' => Application::APP_ID]); + $this->analyze([$params['path']], Monitor::CREATE); } public function onFileWrite(array $params) { - $this->logger->error("Writing ".$params['path'], ['app' => Application::APP_ID]); + $this->logger->error("Writing ".$params['path'], ['app' => Application::APP_ID]); + $this->analyze([$params['path']], Monitor::WRITE); } public function onFileDelete(array $params) { - $this->logger->error("Deleting ".$params['path'], ['app' => Application::APP_ID]); + $this->logger->error("Deleting ".$params['path'], ['app' => Application::APP_ID]); + $this->analyze([$params['path']], Monitor::DELETE); } public function onFileCopy(array $params) { - $this->logger->error("Copying ".$params['path'], ['app' => Application::APP_ID]); + $this->logger->error("Copying ".$params['oldpath']." to ".$params['newpath'], ['app' => Application::APP_ID]); + $this->analyze([$params['oldpath'], $params['newpath']], Monitor::RENAME); } public function onFileTouch(array $params) { - $this->logger->error("Touching ".$params['path'], ['app' => Application::APP_ID]); + $this->logger->error("Touching ".$params['path'], ['app' => Application::APP_ID]); + $this->analyze([$params['path']], Monitor::WRITE); } /** diff --git a/lib/Monitor.php b/lib/Monitor.php index 955d854..e77ba09 100644 --- a/lib/Monitor.php +++ b/lib/Monitor.php @@ -136,7 +136,8 @@ class Monitor public function analyze($paths, $mode) { $path = $paths[0]; - $storage = $this->rootFolder->get(dirname($path))->getStorage(); + + $storage = $this->rootFolder->getUserFolder($this->userId)->get(dirname($path))->getStorage(); if ($this->userId === null || $this->nestingLevel !== 0 || !$this->isUploadedFile($storage, $path) || $this->isCreatingSkeletonFiles()) { // check only cloud files and no system files return; @@ -353,7 +354,11 @@ class Monitor $fullPath = $path; if (property_exists($storage, 'mountPoint')) { /* @var StorageWrapper $storage */ - $fullPath = $storage->mountPoint.$path; + try { + $fullPath = $storage->mountPoint.$path; + } catch (\Exception $ex) { + return false; + } } // ignore transfer files |