Skip to content

Commit

Permalink
Do not react to the update hook when the updated node is a folder
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
paulijar committed Jul 8, 2017
1 parent 5dadb4f commit 07d0be2
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions hooks/filehooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 07d0be2

Please sign in to comment.