Scan files other than www-data

Hello, facing a problem with scanning files.

I have setup nextcloud in a docker container that is on a virtual machine and created a volume for the data.
Now since space is scarce I mounted a shared folder in the VM which contains my comic books:

xxxx@ubuntu:~$ ls -l /mnt/hgfs
drwxrwxrwx 1 root root 4096 Sep 12 13:52 Comic

xxxx@ubuntu:~/docker/nextcloud/data/xxxxx/files/Comics$ ll
drwxr-xr-x 2 www-data www-data 4096 Sep 13 23:19 ./
drwxr-xr-x 5 www-data www-data 4096 Sep 13 23:00 …/
lrwxrwxrwx 1 www-data www-data 16 Sep 13 23:19 Comic → /mnt/hgfs/Comic//
-rw-r–r-- 1 www-data www-data 331285 Sep 13 23:00 DFBZGoSV0AICqC_.mp4

Comic is symbolic link to my mount point /mnt/hgfs/Comic - accessing it I can see all of them so that’s good.

Now I am facing an issue with VMWARE where we can’t change the owner of a shared folder and it’s content from Windows OS (it stays as root), if I do a chown -vR www-data:www-data I see in the verbose output the attempt to change them all but it is reverted immediately back to root:root - so I can’t change them using chown.

Now I tried to mount the shared folder with gid 33 (www-data) in /etc/fstab but it fails and when rebooting the vm get’s stuck because of this line

– So vmware side there is no option to change the ownership from root to www-data.

The only option remains with nextcloud, and therefore I am wondering if thee is any possibility to run a scan and discover files that are owned by root ?

when doing sudo docker exec --user www-data nextcloud php occ files:scan --all -v

The files and folders are scanned again and it does scan the ones that are owned by www-data but not the symlink to the Comic folder and what is contains

If I try on the other hand using root user I get:

xxxx@ubuntu:~/docker/nextcloud/data/xxxx/files/Comics$ sudo docker exec --user root nextcloud php occ files:scan --all -v
Console has to be executed with the user that owns the file config/config.php
Current user: root
Owner of config.php: www-data
Try adding 'sudo -u www-data ' to the beginning of the command (without the single quotes)

So here I decided to chown the config.php file to root:root just for the test and it does scan the files again but not taking the symlink into account (note here changing owner of the config.php prevents the GUI to work):

xxxx@ubuntu:~/docker/nextcloud/data/xxxx/files/Comics$ sudo docker exec --user root nextcloud php occ files:scan --all -v

Starting scan for user 1 out of 1 (xxxx)
Folder /xxxx/
Folder /xxxx/files
File /xxxx/files/Nextcloud Manual.pdf
File /xxxx/files/Nextcloud.mp4
Folder /xxxx/files/Photos
File /xxxx/files/Photos/Coast.jpg
File /xxxx/files/Photos/Hummingbird.jpg
File /xxxx/files/Photos/Nut.jpg
Folder /xxxx/files/Documents
File /xxxx/files/Documents/About.odt
File /xxxx/files/Documents/About.txt
Folder /xxxx/files/Comics
File /xxxx/files/Comics/DFBZGoSV0AICqC_.mp4

±--------±------±-------------+
| Folders | Files | Elapsed time |
±--------±------±-------------+
| 5 | 8 | 00:00:00 |
±--------±------±-------------+

Is there is any possibility to make the scan take into account root owned files and folders ?

AFAIK NC doesn’t do anything with symlinks in the data directory.
Secondly, don’t mount directories within the Nextcloud data directory, instead use the external storage app and connect to the local filesystem that way.

Thanks Jason! So I deleted the symlink. Ran a scan again then tried to use the External Storage as local specifying the /mnt/ and that doesn’t work either:

Checking the logs I get:

stat(): stat failed for /mnt/hgfs/Comic/ at /var/www/html/lib/private/Files/Storage/Local.php#135

&

stat(): stat failed for /mnt/hgfs/ at /var/www/html/lib/private/Files/Storage/Local.php#135

Strangely the latest is empty (/mnt/) but green, even after running a scan again:

sudo docker exec --user www-data nextcloud php occ files:scan --all -v

But the folder is scanned:

Folder /xxxx/files/Comic 3/

Now again this is mounted in Ubuntu Server 16.04 belonging to root:root and I can’t change it.

Sound like related to a path issue if I am not mistaken
https://github.com/nextcloud/server/blob/master/lib/private/Files/Storage/Local.php

public function stat($path) {
clearstatcache();
$fullPath = $this->getSourcePath($path);
$statResult = stat($fullPath);
if (PHP_INT_SIZE === 4 && !$this->is_dir($path)) {
$filesize = $this->filesize($path);
$statResult[‘size’] = $filesize;
$statResult[7] = $filesize;
}
return $statResult;
}