icewind1991 / files_inotify

Adds support detecting changes in local external storages with occ files_external:notify
29 stars 3 forks source link

Don't fail on directories without read/access permission #26

Closed lckarssen closed 1 year ago

lckarssen commented 1 year ago

I am sharing a local directory as external storage in Nextcloud. However, not all subdirectories of it have read/access permission for the www-data/apache user. This leads to the following error, after which files_inotify halts:

$ sudo -u www-data php /var/www/nextcloud/occ files_external:notify -v 1

In NotifyHandler.php line 63:

  [UnexpectedValueException]                                                                                                              
  RecursiveDirectoryIterator::__construct(/local/path/used/as/external_storage/subdir_without_rx_permissions): Failed to open directory: Permission denied                                                                                                                             

Exception trace:
  at /var/www/nextcloud/apps/files_inotify/lib/Storage/NotifyHandler.php:63
 RecursiveDirectoryIterator->__construct() at n/a:n/a
 RecursiveDirectoryIterator->getChildren() at /var/www/nextcloud/apps/files_inotify/lib/Storage/NotifyHandler.php:63
 OCA\Files_INotify\Storage\NotifyHandler->register() at /var/www/nextcloud/apps/files_inotify/lib/Storage/NotifyHandler.php:49
 OCA\Files_INotify\Storage\NotifyHandler->__construct() at /var/www/nextcloud/apps/files_inotify/lib/Storage/INotifyWrapper.php:41
 OCA\Files_INotify\Storage\INotifyWrapper->notify() at /var/www/nextcloud/apps/files_external/lib/Command/Notify.php:194
 OCA\Files_External\Command\Notify->execute() at /var/www/nextcloud/apps/recognize/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at /var/www/nextcloud/core/Command/Base.php:177
 OC\Core\Command\Base->run() at /var/www/nextcloud/apps/recognize/vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at /var/www/nextcloud/apps/recognize/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at /var/www/nextcloud/apps/recognize/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at /var/www/nextcloud/lib/private/Console/Application.php:213
 OC\Console\Application->run() at /var/www/nextcloud/console.php:100
 require_once() at /var/www/nextcloud/occ:11

files_external:notify [-u|--user USER] [-p|--password PASSWORD] [--path PATH] [--no-self-check] [--dry-run] [--output [OUTPUT]] [--] <mount_id>

Would it be possible to ignore (or just log) directories for which the Apache user doesn't have rx permissions?

Possibly related to nextcloud/server#29514.