diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index e33747bbd5219d6e63da351750b9a48c2ba36701..63570d70cff4ba54e1fe04bb7a1c78352484e4ee 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -172,10 +172,19 @@ if (\OC_Util::runningOnWindows()) { } public function rename($path1, $path2) { - if (!$this->isUpdatable($path1)) { - \OC_Log::write('core', 'unable to rename, file is not writable : ' . $path1, \OC_Log::ERROR); + $srcParent = dirname($path1); + $dstParent = dirname($path2); + + if (!$this->isUpdatable($srcParent)) { + \OC_Log::write('core', 'unable to rename, source directory is not writable : ' . $srcParent, \OC_Log::ERROR); return false; } + + if (!$this->isUpdatable($dstParent)) { + \OC_Log::write('core', 'unable to rename, destination directory is not writable : ' . $dstParent, \OC_Log::ERROR); + return false; + } + if (!$this->file_exists($path1)) { \OC_Log::write('core', 'unable to rename, file does not exists : ' . $path1, \OC_Log::ERROR); return false; diff --git a/lib/private/files/storage/mappedlocal.php b/lib/private/files/storage/mappedlocal.php index ea4deaa66e84e1cfba2472035242ed4d6aa4ebd4..6910eef74013111da4d2f78a023457b14f53ba32 100644 --- a/lib/private/files/storage/mappedlocal.php +++ b/lib/private/files/storage/mappedlocal.php @@ -184,10 +184,19 @@ class MappedLocal extends \OC\Files\Storage\Common { } public function rename($path1, $path2) { - if (!$this->isUpdatable($path1)) { - \OC_Log::write('core', 'unable to rename, file is not writable : ' . $path1, \OC_Log::ERROR); + $srcParent = dirname($path1); + $dstParent = dirname($path2); + + if (!$this->isUpdatable($srcParent)) { + \OC_Log::write('core', 'unable to rename, source directory is not writable : ' . $srcParent, \OC_Log::ERROR); return false; } + + if (!$this->isUpdatable($dstParent)) { + \OC_Log::write('core', 'unable to rename, destination directory is not writable : ' . $dstParent, \OC_Log::ERROR); + return false; + } + if (!$this->file_exists($path1)) { \OC_Log::write('core', 'unable to rename, file does not exists : ' . $path1, \OC_Log::ERROR); return false;