mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 23:03:00 -04:00
Merge pull request #38623 from nextcloud/fix/14743/rename-fallback-copy-unlink
fix(storage): fallback to copy and unlink when rename fails
This commit is contained in:
commit
27916deb95
1 changed files with 6 additions and 13 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue