Skip to content
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

trigger a rescan when trying to fopen a file that exists in cache but not on disk #33566

Merged
merged 2 commits into from Oct 1, 2022

Conversation

icewind1991
Copy link
Member

When the file index gets out of sync, any attempt by client to open a deleted (but still in cache) file will result in errors until an admin manually triggers a scan to repair it.

Rather than letting clients loop in errors forever we can just detect this error condition and repair the file index ourselves.

Note that this has no effect on primary object store as there file_exists will check the cache.

@icewind1991 icewind1991 added the 3. to review Waiting for reviews label Aug 16, 2022
@icewind1991 icewind1991 requested review from a team, PVince81, ArtificialOwl and skjnldsv and removed request for a team August 16, 2022 15:28
if (!file_exists($sourcePath)) {
return false;
}
$result = @fopen($sourcePath, $mode);

Check failure

Code scanning / Psalm

TaintedFile

Detected tainted file handling
@icewind1991 icewind1991 force-pushed the fopen-not-found-rescan branch 3 times, most recently from c2709f3 to e64159c Compare August 16, 2022 16:33
@skjnldsv
Copy link
Member

I am facing this on a weekly basis with my dev instance where the data folder get reset frequently! Thanks for diving into this!

@PVince81 PVince81 added this to the Nextcloud 25 milestone Sep 21, 2022
Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see code comments

otherwise the approach looks ok

@blizzz blizzz mentioned this pull request Sep 22, 2022
2 tasks
@blizzz blizzz modified the milestones: Nextcloud 25, Nextcloud 26 Sep 22, 2022
Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991 icewind1991 force-pushed the fopen-not-found-rescan branch 2 times, most recently from 71d33d9 to e32def0 Compare September 29, 2022 08:39
… not on disk

Signed-off-by: Robin Appelman <robin@icewind.nl>
Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@PVince81 PVince81 added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Sep 29, 2022
@blizzz blizzz merged commit ca958de into master Oct 1, 2022
@blizzz blizzz deleted the fopen-not-found-rescan branch October 1, 2022 19:47
@icewind1991
Copy link
Member Author

/backport to stable25

@icewind1991
Copy link
Member Author

/backport to stable24

@icewind1991
Copy link
Member Author

/backport to stable23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants