diff options
author | Vincent Petry <vincent@nextcloud.com> | 2021-11-10 15:09:25 +0100 |
---|---|---|
committer | Vincent Petry <vincent@nextcloud.com> | 2021-11-17 09:24:13 +0100 |
commit | 67ebe75d0ee02977b95e43a31516d936d18514a2 (patch) | |
tree | faabc953b23e23c9415c11d0d578536268bea04f /lib/private/Files/Cache | |
parent | 39fe43b914743985693e6243618109aacf8a3882 (diff) | |
download | nextcloud-server-67ebe75d0ee02977b95e43a31516d936d18514a2.tar.gz nextcloud-server-67ebe75d0ee02977b95e43a31516d936d18514a2.zip |
Move storage encoding compatibility warning logic
The encoding check for file names is now happening the Scanner, and an
event will be emitted only if the storage doesn't contain the encoding
compatibility wrapper.
The event is listened to by the occ scan command to be able to display a
warning in case of file name mismatches when they have NFD encoding.
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'lib/private/Files/Cache')
-rw-r--r-- | lib/private/Files/Cache/Scanner.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php index a88d49d32c2..f31885d54a6 100644 --- a/lib/private/Files/Cache/Scanner.php +++ b/lib/private/Files/Cache/Scanner.php @@ -37,6 +37,7 @@ namespace OC\Files\Cache; use Doctrine\DBAL\Exception; use OC\Files\Filesystem; +use OC\Files\Storage\Wrapper\Encoding; use OC\Hooks\BasicEmitter; use OCP\Files\Cache\IScanner; use OCP\Files\ForbiddenException; @@ -419,8 +420,13 @@ class Scanner extends BasicEmitter implements IScanner { if ($permissions === 0) { continue; } - $file = $fileMeta['name']; - $file = trim(\OC\Files\Filesystem::normalizePath($file), '/'); + $originalFile = $fileMeta['name']; + $file = trim(\OC\Files\Filesystem::normalizePath($originalFile), '/'); + if (trim($originalFile, '/') !== $file && !$this->storage->instanceOfStorage(Encoding::class)) { + // encoding mismatch, might require compatibility wrapper + $this->emit('\OC\Files\Cache\Scanner', 'normalizedNameMismatch', [$path ? $path . '/' . $originalFile : $originalFile]); + } + $newChildNames[] = $file; $child = $path ? $path . '/' . $file : $file; try { |