Occ scan - exclude subdirectories

I have a windows file server with millions of files and some very deep directories. I also have just upwards of 100 users.

Sometimes changes are made to our file system outside the OC approved methods. I would like to run an occ scan --all for all my users but that takes many hours. Using log files, I can identify which folders need to be updated and only update those directories for all my users but when a file change takes place in a higher level directory, the process still takes too long since all subdirectories beneath the effected directory are scanned.

In my ideal world, many of my users would share a common file cache based on group membership. I don’t believe there is anything in OC contemplating this need.

Alternatively, if I can simply scan the directory where file changes took place, without scanning its subdirectories I think this will work. I believe you can exclude directories in the config.php file but this is a static solution whereas my needs are variable.

Does anyone have any suggestions? Many thanks in advance.

Update - I think the solution might be to modify the occ code controlling the file scan process (add a subdir flag?). Unfortunately my php skills are failing me and I’m not quite sure where to start. Any suggestions? Thank you.

One more update:

I believe the line I am looking to edit is in /var/www/owncloud/lib/private/Files/Utils/Scanner.php (line 246)

The current code is
$scanner->scan($relativePath, \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE);

I am looking for a constants file to find an alternative for SCAN_RECURSIVE.

Again, thanks in advance for your help.

SOLUTION:
I should have spent a few more minutes before my last update. There is a constant SCAN_RECURSIVE_INCOMPLETE which does what I want.

2 Likes