TL;DR
| |
If the names come from an old Windows or Samba and are not even UTF-8 (convmv flags them as not UTF-8): convmv -f iso-8859-1 -t utf-8 -r --notest <path>.
On Docker, occ runs inside the container: docker exec -u www-data nextcloud php occ files:scan --all (on the linuxserver.io image, sudo -u abc php /config/www/nextcloud/console.php files:scan --all).
The error
| |
occ files:scan prints it. The files are on disk, ls shows them, but they do not appear on the web, do not sync, and do not count towards quota. It shows up almost always after copying data straight into the data directory (migrations, rsync from a Mac, an SMB share mounted as external storage) instead of uploading through the client.
Why it happens
Unicode allows writing “ñ” two ways: precomposed (NFC, a single code point) or decomposed (NFD, an “n” plus a combining tilde). They look identical and are different bytes. macOS has historically stored names in NFD (HFS+ forced it; APFS and Finder still produce them when copying over SMB or rsync); Linux and Nextcloud work in NFC. Nextcloud normalizes every name to NFC and discards the ones it cannot match with what is on disk, hence the warning.
The other case is older: ISO-8859-1 (Latin-1) names inherited from Windows or from a Samba without unix charset = UTF-8. They are not valid UTF-8 and Nextcloud does not accept them either.
The fix, calmly
- Maintenance mode so no client syncs halfway:
occ maintenance:mode --on. - Simulate:
convmvwithout--notestlists every rename it would do. If files show up as not UTF-8, those go with-f iso-8859-1. - Apply with
--notest. If the NFC twin already exists (the same name uploaded twice),convmvskips it and warns;--replaceoverwrites, so decide beforehand which one is the good one. occ files:scan --all(or--path=/alice/files/Photosfor one user or folder). The warning goes away and the files enter the index.occ maintenance:mode --off.
convmv renames with rename(): it keeps owner, permissions, and dates, and it is instant even with hundreds of thousands of files.
Keeping it from coming back
- From macOS, upload with the Nextcloud client, which normalizes to NFC. If you copy with
rsync,--iconv=utf-8-mac,utf-8converts the names in flight. - Samba as a bridge:
vfs objects = fruitwithfruit:encoding = nativedoes the conversion for Mac clients; andunix charset = UTF-8always. - External storage SMB/local: fix the names at the source; Nextcloud does not rename what it cannot index.
Traps
--notestis what applies. The opposite of what one expects: by defaultconvmvis a dry run.- Renaming changes the
fileid. For Nextcloud, the NFD file disappears and an NFC one is born: shared links, comments, and versions of those files are lost. Warn the affected users first. - ownCloud behaves the same and has the same
occ. - MySQL databases with 3-byte
utf8give a similar but different error (emoji and CJK): there it isocc db:convert-mysql-charset, notconvmv.
See also: Seafile: reclaim space with seaf-gc and rsync: resume large transfers (the --iconv). Reference: thread on help.nextcloud.com.