From 07d0be20d08b9213b69bd299d6ea1dd4613fbcd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pauli=20J=C3=A4rvinen?= Date: Sat, 8 Jul 2017 20:57:03 +0300 Subject: [PATCH] Do not react to the update hook when the updated node is a folder - At least Nextcloud 12 emits the updated signals for folders when the Gallery app creates folder thumbnails. This caused lot of warning being printed to the log output when Scanner noticed that the passed in object was not a file. --- hooks/filehooks.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hooks/filehooks.php b/hooks/filehooks.php index 07a9017d8..3eb74e8ee 100644 --- a/hooks/filehooks.php +++ b/hooks/filehooks.php @@ -45,13 +45,15 @@ public static function deleted($node){ * @param \OCP\Files\Node $node pointing to the file */ public static function updated($node){ - $app = new Music(); - - $container = $app->getContainer(); - $scanner = $container->query('Scanner'); - $userId = $container->query('UserId'); - $userFolder = $container->query('UserFolder'); - $scanner->update($node, $userId, $userFolder); + // we are interested only about updates on files, not on folders + if ($node->getType() == FileInfo::TYPE_FILE) { + $app = new Music(); + $container = $app->getContainer(); + $scanner = $container->query('Scanner'); + $userId = $container->query('UserId'); + $userFolder = $container->query('UserFolder'); + $scanner->update($node, $userId, $userFolder); + } } public function register() {