-
-
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
fix(storage): fallback to copy and unlink when rename fails #38623
Conversation
a890d67
to
083c869
Compare
$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
$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
This comment was marked as resolved.
This comment was marked as resolved.
083c869
to
9122df3
Compare
9122df3
to
ea05970
Compare
ea05970
to
2e6f548
Compare
@@ -335,7 +335,7 @@ private function checkTreeForForbiddenItems(string $path) { | |||
} | |||
} | |||
|
|||
public function rename($source, $target) { | |||
public function rename($source, $target): bool { |
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.
Nice opportunity to type the function params
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2e6f548
to
b4ff557
Compare
Follow-up to change rmdir to unlink: #39644 |
🎉🎉🎉 |
This could happen if a folder is mounted to another drive. The media folder is a good example for this. The problem also occurs in plain Docker containers. The docker magic seems to create different filesystems. This is a known problem (& solution), see: - nextcloud/server#38623 - https://bugs.php.net/bug.php?id=54097
rename()
: The first argument tocopy()
function cannot be a directory #38569Summary
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.1Many thanks again to @kubatek94 for the initial pull request.
TODO
Checklist
Footnotes
https://docs.docker.com/storage/storagedriver/overlayfs-driver/#modifying-files-or-directories ↩