nextcloud / nextcloud/maps

Scan-photo script aborts after access rights of external storage folder changed

Open
#468 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
598
Forks
113
PR merge metrics
No merged PRs in 30d

Description

I have my images in an external folder mounted using SMB. There is another mounted folder with all my other user data - and some jpeg images too. Both are physically located on a Synology NAS. I've withdrawn access to the #recycle - trash bin.

When I do a scan with php occ maps:scan-photos -vvvv beccon - the procedure crashes:

www-data@nextcloud-virt:~/nextcloud$ php occ maps:scan-photos -vvvv beccon                                      
======== User beccon ========                                                                                       
                                                                                                                         
In FailedStorage.php line 210:                                                                                    
                                                                                                           
  [OCP\Files\StorageNotAvailableException (1)]                                                                            
  Storage with mount id 14 is not available                                                                                     
                                                                                                                                 
                                                                                                                                        
Exception trace:                                                                                                            
  at /var/www/nextcloud/lib/private/Files/Storage/FailedStorage.php:210                                      
 OC\Files\Storage\FailedStorage->getAvailability() at /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php:527
 OC\Files\Storage\Wrapper\Wrapper->getAvailability() at /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Availability.php:81           
 OC\Files\Storage\Wrapper\Availability->isAvailable() at /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Availability.php:92
 OC\Files\Storage\Wrapper\Availability->checkAvailability() at /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Availability.php:382
 OC\Files\Storage\Wrapper\Availability->hasUpdated() at /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php:379 
 OC\Files\Storage\Wrapper\Wrapper->hasUpdated() at /var/www/nextcloud/lib/private/Files/Cache/Watcher.php:127               
 OC\Files\Cache\Watcher->needsUpdate() at /var/www/nextcloud/lib/private/Files/View.php:1342                 
 OC\Files\View->getCacheEntry() at /var/www/nextcloud/lib/private/Files/View.php:1445                                                      
 OC\Files\View->getDirectoryContent() at /var/www/nextcloud/lib/private/Files/Node/Folder.php:100                     
 OC\Files\Node\Folder->getDirectoryListing() at /var/www/nextcloud/apps/maps/lib/Service/PhotofilesService.php:322  
 OCA\Maps\Service\PhotofilesService->gatherPhotoFiles() at /var/www/nextcloud/apps/maps/lib/Service/PhotofilesService.php:332
 OCA\Maps\Service\PhotofilesService->gatherPhotoFiles() at /var/www/nextcloud/apps/maps/lib/Service/PhotofilesService.php:67
 OCA\Maps\Service\PhotofilesService->rescan() at /var/www/nextcloud/apps/maps/lib/Command/RescanPhotos.php:80
 OCA\Maps\Command\RescanPhotos->rescanUserPhotos() at /var/www/nextcloud/apps/maps/lib/Command/RescanPhotos.php:71
 OCA\Maps\Command\RescanPhotos->execute() at /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:915
 Symfony\Component\Console\Application->doRunCommand() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:272
 Symfony\Component\Console\Application->doRun() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at /var/www/nextcloud/lib/private/Console/Application.php:214
 OC\Console\Application->run() at /var/www/nextcloud/console.php:99
 require_once() at /var/www/nextcloud/occ:11    

In ConfigAdapter.php line 150:
                                                                            
  [OCP\Files\StorageNotAvailableException (1)]                                            
  Storage with mount id 14 is not available                                            
                                                                                                                                           
                                                                                                                      
Exception trace:                                                                                 
  at /var/www/nextcloud/apps/files_external/lib/Config/ConfigAdapter.php:150
 OCA\Files_External\Config\ConfigAdapter->OCA\Files_External\Config\{closure}() at n/a:n/a
 array_map() at /var/www/nextcloud/apps/files_external/lib/Config/ConfigAdapter.php:145        
 OCA\Files_External\Config\ConfigAdapter->getMountsForUser() at /var/www/nextcloud/lib/private/Files/Config/MountProviderCollection.php:104
 OC\Files\Config\MountProviderCollection->addMountForUser() at /var/www/nextcloud/lib/private/Files/Filesystem.php:448
 OC\Files\Filesystem::initMountPoints() at /var/www/nextcloud/lib/private/Files/Node/Root.php:378                 
 OC\Files\Node\Root->getUserFolder() at n/a:n/a
 call_user_func_array() at /var/www/nextcloud/lib/private/Files/Node/LazyRoot.php:65
 OC\Files\Node\LazyRoot->__call() at /var/www/nextcloud/lib/private/Files/Node/LazyRoot.php:282
 OC\Files\Node\LazyRoot->getUserFolder() at /var/www/nextcloud/apps/maps/lib/Service/PhotofilesService.php:66
 OCA\Maps\Service\PhotofilesService->rescan() at /var/www/nextcloud/apps/maps/lib/Command/RescanPhotos.php:80
 OCA\Maps\Command\RescanPhotos->rescanUserPhotos() at /var/www/nextcloud/apps/maps/lib/Command/RescanPhotos.php:71
 OCA\Maps\Command\RescanPhotos->execute() at /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:915
 Symfony\Component\Console\Application->doRunCommand() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:272
 Symfony\Component\Console\Application->doRun() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at /var/www/nextcloud/lib/private/Console/Application.php:214
 OC\Console\Application->run() at /var/www/nextcloud/console.php:99
 require_once() at /var/www/nextcloud/occ:11

maps:scan-photos [<user_id>]

I suspect it is caused by the change of access rights in the NAS. Nevertheless a external storage can be unavailable from time to time. It should not be cause the script to abort but issue a warning and continue scanning.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with apps/maps/lib/Service/PhotofilesService.php, especially gatherPhotoFiles(), and inspect apps/maps/lib/Command/RescanPhotos.php for the scan entry point. Reproduce with php occ maps:scan-photos -vvvv beccon and trace how StorageNotAvailableException is handled. Done means an unavailable external storage produces a warning and the scan continues instead of aborting.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.