diff options
author | Daniel <mail@danielkesselberg.de> | 2023-07-31 21:04:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-31 21:04:07 +0200 |
commit | 27916deb9508668f570a65ce03504cf507dcbcf7 (patch) | |
tree | 8086205c7147c16d594af3e9d207d2070935a3a4 | |
parent | 48f0e44213efb99dc800a439a824b699ead9446b (diff) | |
parent | b4ff557b8c31ece77b62134720c0d4b68663fbb3 (diff) | |
download | nextcloud-server-27916deb9508668f570a65ce03504cf507dcbcf7.tar.gz nextcloud-server-27916deb9508668f570a65ce03504cf507dcbcf7.zip |
Merge pull request #38623 from nextcloud/fix/14743/rename-fallback-copy-unlink
fix(storage): fallback to copy and unlink when rename fails
-rw-r--r-- | lib/private/Files/Storage/Local.php | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index c0ce0e7021a..fb62a53d894 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -335,7 +335,7 @@ class Local extends \OC\Files\Storage\Common { } } - public function rename($source, $target) { + public function rename($source, $target): bool { $srcParent = dirname($source); $dstParent = dirname($target); @@ -361,21 +361,14 @@ class Local extends \OC\Files\Storage\Common { } if ($this->is_dir($source)) { - // we can't move folders across devices, use copy instead - $stat1 = stat(dirname($this->getSourcePath($source))); - $stat2 = stat(dirname($this->getSourcePath($target))); - if ($stat1['dev'] !== $stat2['dev']) { - $result = $this->copy($source, $target); - if ($result) { - $result &= $this->rmdir($source); - } - return $result; - } - $this->checkTreeForForbiddenItems($this->getSourcePath($source)); } - return rename($this->getSourcePath($source), $this->getSourcePath($target)); + if (@rename($this->getSourcePath($source), $this->getSourcePath($target))) { + return true; + } + + return $this->copy($source, $target) && $this->rmdir($source); } public function copy($source, $target) { |