-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normalize file name before existence check in scanner #29605
Conversation
maybe we could fire another event when we find a file that doesn't match normalization, the scan command can then listen to that one ? |
I guess we can move the compatibility warning to the same place (compare Other than that I think this should be fine |
I've now moved the file name encoding check to the scanner and am firing an event to trigger the warning, but only doing so if the encoding wrapper is not applied. Fixes #29438 as well |
Thinking about this again, it probably makes more sense to add normalization to the output of |
this would only work if the wrapper is applied |
I mean also doing the normalization in the scanner and show the warning the filename isn't normalized when it reaches the scanner (and we should maybe also just ignore it after showing the warning?) |
ok, so the way I understand, after your proposal it would work like this:
|
@icewind1991 I'm looking at DirectoryWrapper but How should I proceed to provide a normalized list from the opendir handle in The only implementation I found is |
It's probably easiest to first collect all files in an array, normalize them, and use |
The scanner would not find a NFD-encoded file name in an existing file list that is normalized. This normalizes the file name before scanning. Fixes issues where scanning repeatedly would make NFD files flicker in and out of existence in the file cache. Signed-off-by: Vincent Petry <[email protected]>
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 <[email protected]>
d862cdc
to
3533cab
Compare
@icewind1991 I had to touch 3 code paths:
the scanner is using getDirectoryContents |
ah, and as per your advice the scanner is now skipping non-normalized names when the encoding wrapper is not in place I just hope that there won't be side effects with other kinds of weird files (non-NFD) that get cleant by the normalization. |
|
Directory entry file names are now normalized in getMetaData(), getDirectoryContents() and opendir(). This makes the scanner work properly as it assumes pre-normalized names. In case the names were not normalized, the scanner will now skip the entries and display a warning when applicable. Signed-off-by: Vincent Petry <[email protected]>
3533cab
to
c92a0e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
/backport to stable23 |
/backport to stable22 |
/backport to stable21 |
Perfect - Fixed in 23.0.0. Thanks. |
The scanner would not find a NFD-encoded file name in an
existing file list that is normalized.
This normalizes the file name before scanning.
Fixes issues where scanning repeatedly would make NFD files flicker in
and out of existence in the file cache both with compatibility mode on and off.
Fixes #29603
TETS: For a quick test with "Local" storage, you need to remove the "isLocal" check on this line: https://github.com/nextcloud/server/blob/master/lib/private/legacy/OC_Util.php#L244