Excludes directories and files from being added to the Nextcloud file cache.
- For files not yet in Nextcloud that match an ignored path: The files will be skipped and will not appear in Nextcloud after future file scans.
- For files already in Nextcloud that match an ignored path: The files will appear in search results, but users will be blocked from accessing them. If a user attempts to open a blocked directory, they will be blocked from creating new files under the directory. Users are also blocked from creating any file or folder that matches any of the rules.
Should be compatible up to Nextcloud 23.x.
- Download a package from the Releases page of this GitHub page.
- Expand the package using
tar -xvzf nextcloud-files-excludedirs-vVERSION.tar.gz
. - Move the expanded
files_excludedirs
folder into yournextcloud/apps
directory, such thatcomposer.json
can be found asnextcloud/apps/files_excludedirs/composer.json
. - Enable the "Exclude directories" plugin under the "Apps" admin page
(
/settings/apps
).
- Ensure that your system has Git and Composer installed.
- Clone this repository into a new subdirectory under your
nextcloud/apps
directory, and name the folderfiles_excludedirs
. - In the
files_excludedirs
subdirectory, runcomposer install
to install required dependencies. - Ensure the
files_excludedirs
subdirectory and all its subdirectories are owned by a user that the Nextcloud user can read (e.g., if NC user is in thewww-data
group, the folder should be owned byroot:www-data
with dir permissions set to0755
and files set to0644
).
The default rule is to exclude paths that match [".snapshot"]
(i.e., to
exclude Btrfs snapshot folders from being indexed).
There is no settings page (yet) for this plugin, but the default rule can be overridden using the Nextcloud CLI using a command like the following:
occ config:app:set files_excludedirs exclude \
--value '[".snapshot","anotherfolder", "pattern/*/match"]'
This will exclude:
- All folders named
.snapshot
. - All folders named
anotherfolder
. - Folders that match the glob pattern
pattern/*/match
, includingpattern/xyz/match
andpattern/abc/match
.
Even with this plugin enabled, neither a file scan (occ files:scan --all
) nor
file cleanup (occ files:cleanup
) is sufficient to remove excluded paths
from the file cache. Instead, you will need to remove these files from the
database using SQL like the following:
DELETE FROM filecache WHERE filecache.path LIKE '%.snapshot%'
Initially authored by Roeland Jago Douma, with contributions from:
- Robin Appelman
- King
- Alan J. Pippin
- Guy Elsmore-Paddock