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

fix(storage): fallback to copy and unlink when rename fails #38623

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

kesselb
Copy link
Contributor

@kesselb kesselb commented Jun 2, 2023

Summary

Alternative approach to #19289

If you use docker's OverlayFS and mount two folders into your container from the same disk it's also not possible to rename, but $stat['dev'] is equal.1

Many thanks again to @kubatek94 for the initial pull request.

TODO

  • CI

Checklist

Footnotes

  1. https://docs.docker.com/storage/storagedriver/overlayfs-driver/#modifying-files-or-directories

lib/private/Files/Storage/Local.php Fixed Show fixed Hide fixed
lib/private/Files/Storage/Local.php Fixed Show fixed Hide fixed
@kesselb kesselb force-pushed the fix/14743/rename-fallback-copy-unlink branch from a890d67 to 083c869 Compare June 2, 2023 21:10
$this->checkTreeForForbiddenItems($this->getSourcePath($source));
}

return rename($this->getSourcePath($source), $this->getSourcePath($target));
if (@rename($this->getSourcePath($source), $this->getSourcePath($target))) {

Check failure

Code scanning / Psalm

TaintedFile

Detected tainted file handling
$this->checkTreeForForbiddenItems($this->getSourcePath($source));
}

return rename($this->getSourcePath($source), $this->getSourcePath($target));
if (@rename($this->getSourcePath($source), $this->getSourcePath($target))) {

Check failure

Code scanning / Psalm

TaintedFile

Detected tainted file handling
@szaimen szaimen added the 2. developing Work in progress label Jun 2, 2023
@szaimen szaimen added this to the Nextcloud 28 milestone Jun 2, 2023
@solracsf

This comment was marked as resolved.

@kesselb kesselb force-pushed the fix/14743/rename-fallback-copy-unlink branch from 083c869 to 9122df3 Compare June 2, 2023 22:03
@kesselb kesselb self-assigned this Jun 3, 2023
@kesselb kesselb added bug 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jun 3, 2023
@@ -335,7 +335,7 @@ private function checkTreeForForbiddenItems(string $path) {
}
}

public function rename($source, $target) {
public function rename($source, $target): bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice opportunity to type the function params

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
@kesselb kesselb force-pushed the fix/14743/rename-fallback-copy-unlink branch from 2e6f548 to b4ff557 Compare July 31, 2023 16:54
@kesselb kesselb merged commit 27916de into master Jul 31, 2023
@kesselb kesselb deleted the fix/14743/rename-fallback-copy-unlink branch July 31, 2023 19:04
@kesselb
Copy link
Contributor Author

kesselb commented Jul 31, 2023

Follow-up to change rmdir to unlink: #39644

@szaimen
Copy link
Contributor

szaimen commented Aug 14, 2023

🎉🎉🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
5 participants