diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Filesystem.php | 8 | ||||
-rw-r--r-- | lib/private/Files/ObjectStore/ObjectStoreStorage.php | 10 | ||||
-rw-r--r-- | lib/private/Files/Storage/Common.php | 30 | ||||
-rw-r--r-- | lib/private/Files/Storage/DAV.php | 46 | ||||
-rw-r--r-- | lib/private/Files/Storage/FailedStorage.php | 4 | ||||
-rw-r--r-- | lib/private/Files/Storage/Local.php | 42 | ||||
-rw-r--r-- | lib/private/Files/Storage/PolyFill/CopyDirectory.php | 14 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Availability.php | 8 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Encoding.php | 16 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Encryption.php | 43 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Jail.php | 16 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/PermissionsMask.php | 12 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Wrapper.php | 16 | ||||
-rw-r--r-- | lib/private/Files/View.php | 126 | ||||
-rw-r--r-- | lib/private/Lockdown/Filesystem/NullStorage.php | 4 | ||||
-rw-r--r-- | lib/public/Files/Storage.php | 12 | ||||
-rw-r--r-- | lib/public/Files/Storage/IStorage.php | 12 |
17 files changed, 209 insertions, 210 deletions
diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php index b9b9534b15f..6c763540847 100644 --- a/lib/private/Files/Filesystem.php +++ b/lib/private/Files/Filesystem.php @@ -599,12 +599,12 @@ class Filesystem { return self::$defaultInstance->unlink($path); } - public static function rename($path1, $path2) { - return self::$defaultInstance->rename($path1, $path2); + public static function rename($source, $target) { + return self::$defaultInstance->rename($source, $target); } - public static function copy($path1, $path2) { - return self::$defaultInstance->copy($path1, $path2); + public static function copy($source, $target) { + return self::$defaultInstance->copy($source, $target); } public static function fopen($path, $mode) { diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 898f64d97c2..b7044c2d894 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -558,17 +558,17 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { return parent::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); } - public function copy($path1, $path2) { - $path1 = $this->normalizePath($path1); - $path2 = $this->normalizePath($path2); + public function copy($source, $target) { + $source = $this->normalizePath($source); + $target = $this->normalizePath($target); $cache = $this->getCache(); - $sourceEntry = $cache->get($path1); + $sourceEntry = $cache->get($source); if (!$sourceEntry) { throw new NotFoundException('Source object not found'); } - $this->copyInner($sourceEntry, $path2); + $this->copyInner($sourceEntry, $target); return true; } diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index a7bc44e10e2..a53ed5d1957 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -213,21 +213,21 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { return $count; } - public function rename($path1, $path2) { - $this->remove($path2); + public function rename($source, $target) { + $this->remove($target); - $this->removeCachedFile($path1); - return $this->copy($path1, $path2) and $this->remove($path1); + $this->removeCachedFile($source); + return $this->copy($source, $target) and $this->remove($source); } - public function copy($path1, $path2) { - if ($this->is_dir($path1)) { - $this->remove($path2); - $dir = $this->opendir($path1); - $this->mkdir($path2); + public function copy($source, $target) { + if ($this->is_dir($source)) { + $this->remove($target); + $dir = $this->opendir($source); + $this->mkdir($target); while ($file = readdir($dir)) { if (!Filesystem::isIgnoredDir($file)) { - if (!$this->copy($path1 . '/' . $file, $path2 . '/' . $file)) { + if (!$this->copy($source . '/' . $file, $target . '/' . $file)) { closedir($dir); return false; } @@ -236,13 +236,13 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { closedir($dir); return true; } else { - $source = $this->fopen($path1, 'r'); - $target = $this->fopen($path2, 'w'); - [, $result] = \OC_Helper::streamCopy($source, $target); + $sourceStream = $this->fopen($source, 'r'); + $targetStream = $this->fopen($target, 'w'); + [, $result] = \OC_Helper::streamCopy($sourceStream, $targetStream); if (!$result) { - \OC::$server->get(LoggerInterface::class)->warning("Failed to write data while copying $path1 to $path2"); + \OCP\Server::get(LoggerInterface::class)->warning("Failed to write data while copying $source to $target"); } - $this->removeCachedFile($path2); + $this->removeCachedFile($target); return $result; } } diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index 132e3d257aa..fcb07cb9748 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -518,30 +518,30 @@ class DAV extends Common { } /** {@inheritdoc} */ - public function rename($path1, $path2) { + public function rename($source, $target) { $this->init(); - $path1 = $this->cleanPath($path1); - $path2 = $this->cleanPath($path2); + $source = $this->cleanPath($source); + $target = $this->cleanPath($target); try { // overwrite directory ? - if ($this->is_dir($path2)) { + if ($this->is_dir($target)) { // needs trailing slash in destination - $path2 = rtrim($path2, '/') . '/'; + $target = rtrim($target, '/') . '/'; } $this->client->request( 'MOVE', - $this->encodePath($path1), + $this->encodePath($source), null, [ - 'Destination' => $this->createBaseUri() . $this->encodePath($path2), + 'Destination' => $this->createBaseUri() . $this->encodePath($target), ] ); - $this->statCache->clear($path1 . '/'); - $this->statCache->clear($path2 . '/'); - $this->statCache->set($path1, false); - $this->statCache->set($path2, true); - $this->removeCachedFile($path1); - $this->removeCachedFile($path2); + $this->statCache->clear($source . '/'); + $this->statCache->clear($target . '/'); + $this->statCache->set($source, false); + $this->statCache->set($target, true); + $this->removeCachedFile($source); + $this->removeCachedFile($target); return true; } catch (\Exception $e) { $this->convertException($e); @@ -550,27 +550,27 @@ class DAV extends Common { } /** {@inheritdoc} */ - public function copy($path1, $path2) { + public function copy($source, $target) { $this->init(); - $path1 = $this->cleanPath($path1); - $path2 = $this->cleanPath($path2); + $source = $this->cleanPath($source); + $target = $this->cleanPath($target); try { // overwrite directory ? - if ($this->is_dir($path2)) { + if ($this->is_dir($target)) { // needs trailing slash in destination - $path2 = rtrim($path2, '/') . '/'; + $target = rtrim($target, '/') . '/'; } $this->client->request( 'COPY', - $this->encodePath($path1), + $this->encodePath($source), null, [ - 'Destination' => $this->createBaseUri() . $this->encodePath($path2), + 'Destination' => $this->createBaseUri() . $this->encodePath($target), ] ); - $this->statCache->clear($path2 . '/'); - $this->statCache->set($path2, true); - $this->removeCachedFile($path2); + $this->statCache->clear($target . '/'); + $this->statCache->set($target, true); + $this->removeCachedFile($target); return true; } catch (\Exception $e) { $this->convertException($e); diff --git a/lib/private/Files/Storage/FailedStorage.php b/lib/private/Files/Storage/FailedStorage.php index 18a2c9c2bb5..482cdc453af 100644 --- a/lib/private/Files/Storage/FailedStorage.php +++ b/lib/private/Files/Storage/FailedStorage.php @@ -129,11 +129,11 @@ class FailedStorage extends Common { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } - public function rename($path1, $path2) { + public function rename($source, $target) { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } - public function copy($path1, $path2) { + public function copy($source, $target) { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 62a04292e23..ff157bfe7f6 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -333,9 +333,9 @@ class Local extends \OC\Files\Storage\Common { } } - public function rename($path1, $path2) { - $srcParent = dirname($path1); - $dstParent = dirname($path2); + public function rename($source, $target) { + $srcParent = dirname($source); + $dstParent = dirname($target); if (!$this->isUpdatable($srcParent)) { \OC::$server->get(LoggerInterface::class)->error('unable to rename, source directory is not writable : ' . $srcParent, ['app' => 'core']); @@ -347,44 +347,44 @@ class Local extends \OC\Files\Storage\Common { return false; } - if (!$this->file_exists($path1)) { - \OC::$server->get(LoggerInterface::class)->error('unable to rename, file does not exists : ' . $path1, ['app' => 'core']); + if (!$this->file_exists($source)) { + \OC::$server->get(LoggerInterface::class)->error('unable to rename, file does not exists : ' . $source, ['app' => 'core']); return false; } - if ($this->is_dir($path2)) { - $this->rmdir($path2); - } elseif ($this->is_file($path2)) { - $this->unlink($path2); + if ($this->is_dir($target)) { + $this->rmdir($target); + } elseif ($this->is_file($target)) { + $this->unlink($target); } - if ($this->is_dir($path1)) { + if ($this->is_dir($source)) { // we can't move folders across devices, use copy instead - $stat1 = stat(dirname($this->getSourcePath($path1))); - $stat2 = stat(dirname($this->getSourcePath($path2))); + $stat1 = stat(dirname($this->getSourcePath($source))); + $stat2 = stat(dirname($this->getSourcePath($target))); if ($stat1['dev'] !== $stat2['dev']) { - $result = $this->copy($path1, $path2); + $result = $this->copy($source, $target); if ($result) { - $result &= $this->rmdir($path1); + $result &= $this->rmdir($source); } return $result; } - $this->checkTreeForForbiddenItems($this->getSourcePath($path1)); + $this->checkTreeForForbiddenItems($this->getSourcePath($source)); } - return rename($this->getSourcePath($path1), $this->getSourcePath($path2)); + return rename($this->getSourcePath($source), $this->getSourcePath($target)); } - public function copy($path1, $path2) { - if ($this->is_dir($path1)) { - return parent::copy($path1, $path2); + public function copy($source, $target) { + if ($this->is_dir($source)) { + return parent::copy($source, $target); } else { $oldMask = umask($this->defUMask); if ($this->unlinkOnTruncate) { - $this->unlink($path2); + $this->unlink($target); } - $result = copy($this->getSourcePath($path1), $this->getSourcePath($path2)); + $result = copy($this->getSourcePath($source), $this->getSourcePath($target)); umask($oldMask); return $result; } diff --git a/lib/private/Files/Storage/PolyFill/CopyDirectory.php b/lib/private/Files/Storage/PolyFill/CopyDirectory.php index 7fd418f6dca..ff05eecb134 100644 --- a/lib/private/Files/Storage/PolyFill/CopyDirectory.php +++ b/lib/private/Files/Storage/PolyFill/CopyDirectory.php @@ -64,15 +64,15 @@ trait CopyDirectory { */ abstract public function mkdir($path); - public function copy($path1, $path2) { - if ($this->is_dir($path1)) { - if ($this->file_exists($path2)) { - $this->unlink($path2); + public function copy($source, $target) { + if ($this->is_dir($source)) { + if ($this->file_exists($target)) { + $this->unlink($target); } - $this->mkdir($path2); - return $this->copyRecursive($path1, $path2); + $this->mkdir($target); + return $this->copyRecursive($source, $target); } else { - return parent::copy($path1, $path2); + return parent::copy($source, $target); } } diff --git a/lib/private/Files/Storage/Wrapper/Availability.php b/lib/private/Files/Storage/Wrapper/Availability.php index 910ea369757..a4a6fa0bd16 100644 --- a/lib/private/Files/Storage/Wrapper/Availability.php +++ b/lib/private/Files/Storage/Wrapper/Availability.php @@ -288,20 +288,20 @@ class Availability extends Wrapper { } /** {@inheritdoc} */ - public function rename($path1, $path2) { + public function rename($source, $target) { $this->checkAvailability(); try { - return parent::rename($path1, $path2); + return parent::rename($source, $target); } catch (StorageNotAvailableException $e) { $this->setUnavailable($e); } } /** {@inheritdoc} */ - public function copy($path1, $path2) { + public function copy($source, $target) { $this->checkAvailability(); try { - return parent::copy($path1, $path2); + return parent::copy($source, $target); } catch (StorageNotAvailableException $e) { $this->setUnavailable($e); } diff --git a/lib/private/Files/Storage/Wrapper/Encoding.php b/lib/private/Files/Storage/Wrapper/Encoding.php index ac9cc248ce6..cb82e00845c 100644 --- a/lib/private/Files/Storage/Wrapper/Encoding.php +++ b/lib/private/Files/Storage/Wrapper/Encoding.php @@ -338,24 +338,24 @@ class Encoding extends Wrapper { /** * see https://www.php.net/manual/en/function.rename.php * - * @param string $path1 - * @param string $path2 + * @param string $source + * @param string $target * @return bool */ - public function rename($path1, $path2) { + public function rename($source, $target) { // second name always NFC - return $this->storage->rename($this->findPathToUse($path1), $this->findPathToUse($path2)); + return $this->storage->rename($this->findPathToUse($source), $this->findPathToUse($target)); } /** * see https://www.php.net/manual/en/function.copy.php * - * @param string $path1 - * @param string $path2 + * @param string $source + * @param string $target * @return bool */ - public function copy($path1, $path2) { - return $this->storage->copy($this->findPathToUse($path1), $this->findPathToUse($path2)); + public function copy($source, $target) { + return $this->storage->copy($this->findPathToUse($source), $this->findPathToUse($target)); } /** diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index d5bf929101f..21db6b7bf9d 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -270,28 +270,28 @@ class Encryption extends Wrapper { /** * see https://www.php.net/manual/en/function.rename.php * - * @param string $path1 - * @param string $path2 + * @param string $source + * @param string $target * @return bool */ - public function rename($path1, $path2) { - $result = $this->storage->rename($path1, $path2); + public function rename($source, $target) { + $result = $this->storage->rename($source, $target); if ($result && // versions always use the keys from the original file, so we can skip // this step for versions - $this->isVersion($path2) === false && + $this->isVersion($target) === false && $this->encryptionManager->isEnabled()) { - $source = $this->getFullPath($path1); - if (!$this->util->isExcluded($source)) { - $target = $this->getFullPath($path2); - if (isset($this->unencryptedSize[$source])) { - $this->unencryptedSize[$target] = $this->unencryptedSize[$source]; + $sourcePath = $this->getFullPath($source); + if (!$this->util->isExcluded($sourcePath)) { + $targetPath = $this->getFullPath($target); + if (isset($this->unencryptedSize[$sourcePath])) { + $this->unencryptedSize[$targetPath] = $this->unencryptedSize[$sourcePath]; } - $this->keyStorage->renameKeys($source, $target); - $module = $this->getEncryptionModule($path2); + $this->keyStorage->renameKeys($sourcePath, $targetPath); + $module = $this->getEncryptionModule($target); if ($module) { - $module->update($target, $this->uid, []); + $module->update($targetPath, $this->uid, []); } } } @@ -344,21 +344,20 @@ class Encryption extends Wrapper { /** * see https://www.php.net/manual/en/function.copy.php * - * @param string $path1 - * @param string $path2 - * @return bool + * @param string $source + * @param string $target */ - public function copy($path1, $path2) { - $source = $this->getFullPath($path1); + public function copy($source, $target): bool { + $sourcePath = $this->getFullPath($source); - if ($this->util->isExcluded($source)) { - return $this->storage->copy($path1, $path2); + if ($this->util->isExcluded($sourcePath)) { + return $this->storage->copy($source, $target); } // need to stream copy file by file in case we copy between a encrypted // and a unencrypted storage - $this->unlink($path2); - return $this->copyFromStorage($this, $path1, $path2); + $this->unlink($target); + return $this->copyFromStorage($this, $source, $target); } /** diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php index 65ee6f1181a..9834ae5a954 100644 --- a/lib/private/Files/Storage/Wrapper/Jail.php +++ b/lib/private/Files/Storage/Wrapper/Jail.php @@ -281,23 +281,23 @@ class Jail extends Wrapper { /** * see https://www.php.net/manual/en/function.rename.php * - * @param string $path1 - * @param string $path2 + * @param string $source + * @param string $target * @return bool */ - public function rename($path1, $path2) { - return $this->getWrapperStorage()->rename($this->getUnjailedPath($path1), $this->getUnjailedPath($path2)); + public function rename($source, $target) { + return $this->getWrapperStorage()->rename($this->getUnjailedPath($source), $this->getUnjailedPath($target)); } /** * see https://www.php.net/manual/en/function.copy.php * - * @param string $path1 - * @param string $path2 + * @param string $source + * @param string $target * @return bool */ - public function copy($path1, $path2) { - return $this->getWrapperStorage()->copy($this->getUnjailedPath($path1), $this->getUnjailedPath($path2)); + public function copy($source, $target) { + return $this->getWrapperStorage()->copy($this->getUnjailedPath($source), $this->getUnjailedPath($target)); } /** diff --git a/lib/private/Files/Storage/Wrapper/PermissionsMask.php b/lib/private/Files/Storage/Wrapper/PermissionsMask.php index e54d3bb721a..0d140e0a39d 100644 --- a/lib/private/Files/Storage/Wrapper/PermissionsMask.php +++ b/lib/private/Files/Storage/Wrapper/PermissionsMask.php @@ -78,16 +78,16 @@ class PermissionsMask extends Wrapper { return $this->storage->getPermissions($path) & $this->mask; } - public function rename($path1, $path2) { + public function rename($source, $target) { //This is a rename of the transfer file to the original file - if (dirname($path1) === dirname($path2) && strpos($path1, '.ocTransferId') > 0) { - return $this->checkMask(Constants::PERMISSION_CREATE) and parent::rename($path1, $path2); + if (dirname($source) === dirname($target) && strpos($source, '.ocTransferId') > 0) { + return $this->checkMask(Constants::PERMISSION_CREATE) and parent::rename($source, $target); } - return $this->checkMask(Constants::PERMISSION_UPDATE) and parent::rename($path1, $path2); + return $this->checkMask(Constants::PERMISSION_UPDATE) and parent::rename($source, $target); } - public function copy($path1, $path2) { - return $this->checkMask(Constants::PERMISSION_CREATE) and parent::copy($path1, $path2); + public function copy($source, $target) { + return $this->checkMask(Constants::PERMISSION_CREATE) and parent::copy($source, $target); } public function touch($path, $mtime = null) { diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index 6bc66bf9c89..ed7e137fd88 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -271,23 +271,23 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea /** * see https://www.php.net/manual/en/function.rename.php * - * @param string $path1 - * @param string $path2 + * @param string $source + * @param string $target * @return bool */ - public function rename($path1, $path2) { - return $this->getWrapperStorage()->rename($path1, $path2); + public function rename($source, $target) { + return $this->getWrapperStorage()->rename($source, $target); } /** * see https://www.php.net/manual/en/function.copy.php * - * @param string $path1 - * @param string $path2 + * @param string $source + * @param string $target * @return bool */ - public function copy($path1, $path2) { - return $this->getWrapperStorage()->copy($path1, $path2); + public function copy($source, $target) { + return $this->getWrapperStorage()->copy($source, $target); } /** diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 986aecf556f..0abc870dc6f 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -749,65 +749,65 @@ class View { /** * Rename/move a file or folder from the source path to target path. * - * @param string $path1 source path - * @param string $path2 target path + * @param string $source source path + * @param string $target target path * * @return bool|mixed * @throws LockedException */ - public function rename($path1, $path2) { - $absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($path1)); - $absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($path2)); + public function rename($source, $target) { + $absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($source)); + $absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($target)); $result = false; if ( - Filesystem::isValidPath($path2) - and Filesystem::isValidPath($path1) - and !Filesystem::isFileBlacklisted($path2) + Filesystem::isValidPath($target) + and Filesystem::isValidPath($source) + and !Filesystem::isFileBlacklisted($target) ) { - $path1 = $this->getRelativePath($absolutePath1); - $path2 = $this->getRelativePath($absolutePath2); - $exists = $this->file_exists($path2); + $source = $this->getRelativePath($absolutePath1); + $target = $this->getRelativePath($absolutePath2); + $exists = $this->file_exists($target); - if ($path1 == null or $path2 == null) { + if ($source == null or $target == null) { return false; } - $this->lockFile($path1, ILockingProvider::LOCK_SHARED, true); + $this->lockFile($source, ILockingProvider::LOCK_SHARED, true); try { - $this->lockFile($path2, ILockingProvider::LOCK_SHARED, true); + $this->lockFile($target, ILockingProvider::LOCK_SHARED, true); $run = true; - if ($this->shouldEmitHooks($path1) && (Cache\Scanner::isPartialFile($path1) && !Cache\Scanner::isPartialFile($path2))) { + if ($this->shouldEmitHooks($source) && (Cache\Scanner::isPartialFile($source) && !Cache\Scanner::isPartialFile($target))) { // if it was a rename from a part file to a regular file it was a write and not a rename operation - $this->emit_file_hooks_pre($exists, $path2, $run); - } elseif ($this->shouldEmitHooks($path1)) { + $this->emit_file_hooks_pre($exists, $target, $run); + } elseif ($this->shouldEmitHooks($source)) { \OC_Hook::emit( Filesystem::CLASSNAME, Filesystem::signal_rename, [ - Filesystem::signal_param_oldpath => $this->getHookPath($path1), - Filesystem::signal_param_newpath => $this->getHookPath($path2), + Filesystem::signal_param_oldpath => $this->getHookPath($source), + Filesystem::signal_param_newpath => $this->getHookPath($target), Filesystem::signal_param_run => &$run ] ); } if ($run) { - $this->verifyPath(dirname($path2), basename($path2)); + $this->verifyPath(dirname($target), basename($target)); $manager = Filesystem::getMountManager(); - $mount1 = $this->getMount($path1); - $mount2 = $this->getMount($path2); + $mount1 = $this->getMount($source); + $mount2 = $this->getMount($target); $storage1 = $mount1->getStorage(); $storage2 = $mount2->getStorage(); $internalPath1 = $mount1->getInternalPath($absolutePath1); $internalPath2 = $mount2->getInternalPath($absolutePath2); - $this->changeLock($path1, ILockingProvider::LOCK_EXCLUSIVE, true); + $this->changeLock($source, ILockingProvider::LOCK_EXCLUSIVE, true); try { - $this->changeLock($path2, ILockingProvider::LOCK_EXCLUSIVE, true); + $this->changeLock($target, ILockingProvider::LOCK_EXCLUSIVE, true); if ($internalPath1 === '') { if ($mount1 instanceof MoveableMount) { - $sourceParentMount = $this->getMount(dirname($path1)); + $sourceParentMount = $this->getMount(dirname($source)); if ($sourceParentMount === $mount2 && $this->targetIsNotShared($storage2, $internalPath2)) { /** * @var \OC\Files\Mount\MountPoint | \OC\Files\Mount\MoveableMount $mount1 @@ -833,7 +833,7 @@ class View { $result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2); } - if ((Cache\Scanner::isPartialFile($path1) && !Cache\Scanner::isPartialFile($path2)) && $result !== false) { + if ((Cache\Scanner::isPartialFile($source) && !Cache\Scanner::isPartialFile($target)) && $result !== false) { // if it was a rename from a part file to a regular file it was a write and not a rename operation $this->writeUpdate($storage2, $internalPath2); } elseif ($result) { @@ -844,22 +844,22 @@ class View { } catch (\Exception $e) { throw $e; } finally { - $this->changeLock($path1, ILockingProvider::LOCK_SHARED, true); - $this->changeLock($path2, ILockingProvider::LOCK_SHARED, true); + $this->changeLock($source, ILockingProvider::LOCK_SHARED, true); + $this->changeLock($target, ILockingProvider::LOCK_SHARED, true); } - if ((Cache\Scanner::isPartialFile($path1) && !Cache\Scanner::isPartialFile($path2)) && $result !== false) { + if ((Cache\Scanner::isPartialFile($source) && !Cache\Scanner::isPartialFile($target)) && $result !== false) { if ($this->shouldEmitHooks()) { - $this->emit_file_hooks_post($exists, $path2); + $this->emit_file_hooks_post($exists, $target); } } elseif ($result) { - if ($this->shouldEmitHooks($path1) and $this->shouldEmitHooks($path2)) { + if ($this->shouldEmitHooks($source) and $this->shouldEmitHooks($target)) { \OC_Hook::emit( Filesystem::CLASSNAME, Filesystem::signal_post_rename, [ - Filesystem::signal_param_oldpath => $this->getHookPath($path1), - Filesystem::signal_param_newpath => $this->getHookPath($path2) + Filesystem::signal_param_oldpath => $this->getHookPath($source), + Filesystem::signal_param_newpath => $this->getHookPath($target) ] ); } @@ -868,8 +868,8 @@ class View { } catch (\Exception $e) { throw $e; } finally { - $this->unlockFile($path1, ILockingProvider::LOCK_SHARED, true); - $this->unlockFile($path2, ILockingProvider::LOCK_SHARED, true); + $this->unlockFile($source, ILockingProvider::LOCK_SHARED, true); + $this->unlockFile($target, ILockingProvider::LOCK_SHARED, true); } } return $result; @@ -878,57 +878,57 @@ class View { /** * Copy a file/folder from the source path to target path * - * @param string $path1 source path - * @param string $path2 target path + * @param string $source source path + * @param string $target target path * @param bool $preserveMtime whether to preserve mtime on the copy * * @return bool|mixed */ - public function copy($path1, $path2, $preserveMtime = false) { - $absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($path1)); - $absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($path2)); + public function copy($source, $target, $preserveMtime = false) { + $absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($source)); + $absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($target)); $result = false; if ( - Filesystem::isValidPath($path2) - and Filesystem::isValidPath($path1) - and !Filesystem::isFileBlacklisted($path2) + Filesystem::isValidPath($target) + and Filesystem::isValidPath($source) + and !Filesystem::isFileBlacklisted($target) ) { - $path1 = $this->getRelativePath($absolutePath1); - $path2 = $this->getRelativePath($absolutePath2); + $source = $this->getRelativePath($absolutePath1); + $target = $this->getRelativePath($absolutePath2); - if ($path1 == null or $path2 == null) { + if ($source == null or $target == null) { return false; } $run = true; - $this->lockFile($path2, ILockingProvider::LOCK_SHARED); - $this->lockFile($path1, ILockingProvider::LOCK_SHARED); + $this->lockFile($target, ILockingProvider::LOCK_SHARED); + $this->lockFile($source, ILockingProvider::LOCK_SHARED); $lockTypePath1 = ILockingProvider::LOCK_SHARED; $lockTypePath2 = ILockingProvider::LOCK_SHARED; try { - $exists = $this->file_exists($path2); + $exists = $this->file_exists($target); if ($this->shouldEmitHooks()) { \OC_Hook::emit( Filesystem::CLASSNAME, Filesystem::signal_copy, [ - Filesystem::signal_param_oldpath => $this->getHookPath($path1), - Filesystem::signal_param_newpath => $this->getHookPath($path2), + Filesystem::signal_param_oldpath => $this->getHookPath($source), + Filesystem::signal_param_newpath => $this->getHookPath($target), Filesystem::signal_param_run => &$run ] ); - $this->emit_file_hooks_pre($exists, $path2, $run); + $this->emit_file_hooks_pre($exists, $target, $run); } if ($run) { - $mount1 = $this->getMount($path1); - $mount2 = $this->getMount($path2); + $mount1 = $this->getMount($source); + $mount2 = $this->getMount($target); $storage1 = $mount1->getStorage(); $internalPath1 = $mount1->getInternalPath($absolutePath1); $storage2 = $mount2->getStorage(); $internalPath2 = $mount2->getInternalPath($absolutePath2); - $this->changeLock($path2, ILockingProvider::LOCK_EXCLUSIVE); + $this->changeLock($target, ILockingProvider::LOCK_EXCLUSIVE); $lockTypePath2 = ILockingProvider::LOCK_EXCLUSIVE; if ($mount1->getMountPoint() == $mount2->getMountPoint()) { @@ -943,7 +943,7 @@ class View { $this->writeUpdate($storage2, $internalPath2); - $this->changeLock($path2, ILockingProvider::LOCK_SHARED); + $this->changeLock($target, ILockingProvider::LOCK_SHARED); $lockTypePath2 = ILockingProvider::LOCK_SHARED; if ($this->shouldEmitHooks() && $result !== false) { @@ -951,21 +951,21 @@ class View { Filesystem::CLASSNAME, Filesystem::signal_post_copy, [ - Filesystem::signal_param_oldpath => $this->getHookPath($path1), - Filesystem::signal_param_newpath => $this->getHookPath($path2) + Filesystem::signal_param_oldpath => $this->getHookPath($source), + Filesystem::signal_param_newpath => $this->getHookPath($target) ] ); - $this->emit_file_hooks_post($exists, $path2); + $this->emit_file_hooks_post($exists, $target); } } } catch (\Exception $e) { - $this->unlockFile($path2, $lockTypePath2); - $this->unlockFile($path1, $lockTypePath1); + $this->unlockFile($target, $lockTypePath2); + $this->unlockFile($source, $lockTypePath1); throw $e; } - $this->unlockFile($path2, $lockTypePath2); - $this->unlockFile($path1, $lockTypePath1); + $this->unlockFile($target, $lockTypePath2); + $this->unlockFile($source, $lockTypePath1); } return $result; } diff --git a/lib/private/Lockdown/Filesystem/NullStorage.php b/lib/private/Lockdown/Filesystem/NullStorage.php index ac8c30418bd..8427a4658d4 100644 --- a/lib/private/Lockdown/Filesystem/NullStorage.php +++ b/lib/private/Lockdown/Filesystem/NullStorage.php @@ -113,11 +113,11 @@ class NullStorage extends Common { throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); } - public function rename($path1, $path2) { + public function rename($source, $target) { throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); } - public function copy($path1, $path2) { + public function copy($source, $target) { throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); } diff --git a/lib/public/Files/Storage.php b/lib/public/Files/Storage.php index 0a1a504b137..6f5a2f53673 100644 --- a/lib/public/Files/Storage.php +++ b/lib/public/Files/Storage.php @@ -244,22 +244,22 @@ interface Storage extends IStorage { /** * see https://www.php.net/manual/en/function.rename.php * - * @param string $path1 - * @param string $path2 + * @param string $source + * @param string $target * @return bool * @since 6.0.0 */ - public function rename($path1, $path2); + public function rename($source, $target); /** * see https://www.php.net/manual/en/function.copy.php * - * @param string $path1 - * @param string $path2 + * @param string $soruce + * @param string $target * @return bool * @since 6.0.0 */ - public function copy($path1, $path2); + public function copy($source, $target); /** * see https://www.php.net/manual/en/function.fopen.php diff --git a/lib/public/Files/Storage/IStorage.php b/lib/public/Files/Storage/IStorage.php index f42eb81bfec..eb5522909c6 100644 --- a/lib/public/Files/Storage/IStorage.php +++ b/lib/public/Files/Storage/IStorage.php @@ -241,22 +241,22 @@ interface IStorage { /** * see https://www.php.net/manual/en/function.rename.php * - * @param string $path1 - * @param string $path2 + * @param string $source + * @param string $target * @return bool * @since 9.0.0 */ - public function rename($path1, $path2); + public function rename($source, $target); /** * see https://www.php.net/manual/en/function.copy.php * - * @param string $path1 - * @param string $path2 + * @param string $source + * @param string $target * @return bool * @since 9.0.0 */ - public function copy($path1, $path2); + public function copy($source, $target); /** * see https://www.php.net/manual/en/function.fopen.php |