-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
fix: Filter for folders in cleanup old preview job #48581
Conversation
Same as #46072? |
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
c6e208b
to
f074020
Compare
As the above mentioned PR seems to be staled, I rebased and refined this one. It now also incorporates the second improvement made in 0c7eeec for the job also ignoring non-numeric named directories. |
f074020
to
ab1b0a8
Compare
Additionally tagging @Altahrim, @blizzz and @nickvergessen for requesting a review. |
Can you please explain why this PR is better than #46072 ? |
@solracsf Sure thing:
|
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.
This REGEX thing is a bit scary but I suppose if the tests pass on all DB we should be fine?
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.
Is the regexp part actually needed? What kind of directory were selected when they should not be?
ab1b0a8
to
b049e48
Compare
@artonge The RegExp is only needed for the following reason: However, what this (and the above mentioned PR) try to fix/implement is a fix to the issue where a user wants, for whatever reason, create arbitrary files/folders there, for example a The first change already filters out any file, as the query filters by the I personally do not see the use-case for supporting arbitrary folders in this directory, which is why I initially did not implement this, however I wanted to reimplement the added support for this from the other PR, while not massively tanking its performance while doing so. tl;dr: It is needed, if we also want to support arbitrary, user-created folders in the preview appdata directory, otherwise not, which would massively simplify this PR (as it was in its previous form). |
@hammer065 Thank you for your work on this and explanations. But that’s quite a niche cornercase, and the code after should survive. Worst case scenario I think it will delete a folder in the preview folder which should not be there in the first place. So all in all I would vote for the simpler version of the PR without the regex usage. Maybe we can keep the regex implementation the queryBuilder though, it may prove useful some day. |
Thanks for the detailed summary @hammer065. On my side, I indeed don't see the point in introducing such logic for a hypothetical edge case.
I would especially be against, as "all non-numeric folder names" would probably be only one. |
Not sure about the performance of such operator. Unless it is fast, having it in by default might lead to being it use without knowing better and causing performance issues. If we don't have a use case, let's not keep it. |
Please let me know what the end position is after your (internal) discussions, so I can adapt the PR accordingly. My personal stances are to both not support arbitrary folders, just files, in the previews directory and not to keep the RegEx code. |
We agree, please remove regex related code and keep the changes minimal, it will also be easier to backport. |
Fixes nextcloud#35936. When running `OC\Preview\BackgroundCleanupJob`, the main iteration loop in `run()` expects a folder, however, `getOldPreviewLocations()` currently does not filter by mimetype and therefore can yield a non-folder entry which causes an Exception when constructing the Folder impl. Filtering for `httpd/unix-directory`, as `getNewPreviewLocations()` already does, fixes this issue. Signed-off-by: Dario Mehlich <[email protected]>
b049e48
to
8c30913
Compare
@come-nc Done, you can review this now (finally) final commit :D |
/backport to stable31 |
/backport to stable30 |
/backport to stable29 |
Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 |
@hammer065 Thanks a lot for your patience and team work here! Would you be interested in a Guest account on our Nextcloud Talk instance where we host a dev chat? |
|
I invited you on the email used for the commit sign-off. |
Summary
When running
OC\Preview\BackgroundCleanupJob
, the main iteration loop inrun()
expects a folder,however,
getOldPreviewLocations()
currently does not filter by mimetypeand therefore can yield a non-folder entry which causes an Exception when constructing the Folder impl.
Filtering for
httpd/unix-directory
, asgetNewPreviewLocations()
already does, fixes this issue.Checklist