aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Lib
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-10-18 12:49:34 +0200
committerCarl Schwan <carl@carlschwan.eu>2022-10-18 17:21:47 +0200
commita5ea677370df4479cc309f4c359599590c24f278 (patch)
treecd861667f467b31ff58ecf39613507432eb83d35 /apps/files_external/lib/Lib
parent732badf552c91733192e87d6ceb2848b4b75d439 (diff)
downloadnextcloud-server-a5ea677370df4479cc309f4c359599590c24f278.tar.gz
nextcloud-server-a5ea677370df4479cc309f4c359599590c24f278.zip
Rename file1 and file2 to source and target in Storage abstraction
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/files_external/lib/Lib')
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php44
-rw-r--r--apps/files_external/lib/Lib/Storage/FTP.php6
-rw-r--r--apps/files_external/lib/Lib/Storage/FtpConnection.php4
-rw-r--r--apps/files_external/lib/Lib/Storage/SFTP.php10
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php16
-rw-r--r--apps/files_external/lib/Lib/Storage/StreamWrapper.php4
-rw-r--r--apps/files_external/lib/Lib/Storage/Swift.php50
7 files changed, 67 insertions, 67 deletions
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index 0424f337881..9e91b89d29e 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -574,16 +574,16 @@ class AmazonS3 extends \OC\Files\Storage\Common {
return true;
}
- public function copy($path1, $path2, $isFile = null) {
- $path1 = $this->normalizePath($path1);
- $path2 = $this->normalizePath($path2);
+ public function copy($source, $target, $isFile = null) {
+ $source = $this->normalizePath($source);
+ $target = $this->normalizePath($target);
- if ($isFile === true || $this->is_file($path1)) {
+ if ($isFile === true || $this->is_file($source)) {
try {
$this->getConnection()->copyObject([
'Bucket' => $this->bucket,
- 'Key' => $this->cleanKey($path2),
- 'CopySource' => S3Client::encodeKey($this->bucket . '/' . $path1)
+ 'Key' => $this->cleanKey($target),
+ 'CopySource' => S3Client::encodeKey($this->bucket . '/' . $source)
]);
$this->testTimeout();
} catch (S3Exception $e) {
@@ -594,10 +594,10 @@ class AmazonS3 extends \OC\Files\Storage\Common {
return false;
}
} else {
- $this->remove($path2);
+ $this->remove($target);
try {
- $this->mkdir($path2);
+ $this->mkdir($target);
$this->testTimeout();
} catch (S3Exception $e) {
$this->logger->error($e->getMessage(), [
@@ -607,38 +607,38 @@ class AmazonS3 extends \OC\Files\Storage\Common {
return false;
}
- foreach ($this->getDirectoryContent($path1) as $item) {
- $source = $path1 . '/' . $item['name'];
- $target = $path2 . '/' . $item['name'];
+ foreach ($this->getDirectoryContent($source) as $item) {
+ $source = $source . '/' . $item['name'];
+ $target = $target . '/' . $item['name'];
$this->copy($source, $target, $item['mimetype'] !== FileInfo::MIMETYPE_FOLDER);
}
}
- $this->invalidateCache($path2);
+ $this->invalidateCache($target);
return true;
}
- public function rename($path1, $path2) {
- $path1 = $this->normalizePath($path1);
- $path2 = $this->normalizePath($path2);
+ public function rename($source, $target) {
+ $source = $this->normalizePath($source);
+ $target = $this->normalizePath($target);
- if ($this->is_file($path1)) {
- if ($this->copy($path1, $path2) === false) {
+ if ($this->is_file($source)) {
+ if ($this->copy($source, $target) === false) {
return false;
}
- if ($this->unlink($path1) === false) {
- $this->unlink($path2);
+ if ($this->unlink($source) === false) {
+ $this->unlink($target);
return false;
}
} else {
- if ($this->copy($path1, $path2) === false) {
+ if ($this->copy($source, $target) === false) {
return false;
}
- if ($this->rmdir($path1) === false) {
- $this->rmdir($path2);
+ if ($this->rmdir($source) === false) {
+ $this->rmdir($target);
return false;
}
}
diff --git a/apps/files_external/lib/Lib/Storage/FTP.php b/apps/files_external/lib/Lib/Storage/FTP.php
index d424ffe3cdd..0350035a11a 100644
--- a/apps/files_external/lib/Lib/Storage/FTP.php
+++ b/apps/files_external/lib/Lib/Storage/FTP.php
@@ -333,9 +333,9 @@ class FTP extends Common {
}
}
- public function rename($path1, $path2) {
- $this->unlink($path2);
- return $this->getConnection()->rename($this->buildPath($path1), $this->buildPath($path2));
+ public function rename($source, $target) {
+ $this->unlink($target);
+ return $this->getConnection()->rename($this->buildPath($source), $this->buildPath($target));
}
public function getDirectoryContent($directory): \Traversable {
diff --git a/apps/files_external/lib/Lib/Storage/FtpConnection.php b/apps/files_external/lib/Lib/Storage/FtpConnection.php
index bc4be18e42e..c6f9a5c91b0 100644
--- a/apps/files_external/lib/Lib/Storage/FtpConnection.php
+++ b/apps/files_external/lib/Lib/Storage/FtpConnection.php
@@ -85,8 +85,8 @@ class FtpConnection {
return @ftp_rmdir($this->connection, $path);
}
- public function rename(string $path1, string $path2) {
- return @ftp_rename($this->connection, $path1, $path2);
+ public function rename(string $source, string $target) {
+ return @ftp_rename($this->connection, $source, $target);
}
public function mdtm(string $path) {
diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php
index faf51369375..e46f60d0be4 100644
--- a/apps/files_external/lib/Lib/Storage/SFTP.php
+++ b/apps/files_external/lib/Lib/Storage/SFTP.php
@@ -435,14 +435,14 @@ class SFTP extends \OC\Files\Storage\Common {
/**
* {@inheritdoc}
*/
- public function rename($path1, $path2) {
+ public function rename($source, $target) {
try {
- if ($this->file_exists($path2)) {
- $this->unlink($path2);
+ if ($this->file_exists($target)) {
+ $this->unlink($target);
}
return $this->getConnection()->rename(
- $this->absPath($path1),
- $this->absPath($path2)
+ $this->absPath($source),
+ $this->absPath($target)
);
} catch (\Exception $e) {
return false;
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index 7e297885ded..1d4cf5a7a2e 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -306,22 +306,22 @@ class SMB extends Common implements INotifyStorage {
/**
* Rename the files. If the source or the target is the root, the rename won't happen.
*
- * @param string $path1 the old name of the path
- * @param string $path2 the new name of the path
+ * @param string $source the old name of the path
+ * @param string $target the new name of the path
* @return bool true if the rename is successful, false otherwise
*/
- public function rename($path1, $path2, $retry = true) {
- if ($this->isRootDir($path1) || $this->isRootDir($path2)) {
+ public function rename($source, $target, $retry = true): bool {
+ if ($this->isRootDir($source) || $this->isRootDir($target)) {
return false;
}
- $absoluteSource = $this->buildPath($path1);
- $absoluteTarget = $this->buildPath($path2);
+ $absoluteSource = $this->buildPath($source);
+ $absoluteTarget = $this->buildPath($target);
try {
$result = $this->share->rename($absoluteSource, $absoluteTarget);
} catch (AlreadyExistsException $e) {
if ($retry) {
- $this->remove($path2);
+ $this->remove($target);
$result = $this->share->rename($absoluteSource, $absoluteTarget);
} else {
$this->logger->logException($e, ['level' => ILogger::WARN]);
@@ -329,7 +329,7 @@ class SMB extends Common implements INotifyStorage {
}
} catch (InvalidArgumentException $e) {
if ($retry) {
- $this->remove($path2);
+ $this->remove($target);
$result = $this->share->rename($absoluteSource, $absoluteTarget);
} else {
$this->logger->logException($e, ['level' => ILogger::WARN]);
diff --git a/apps/files_external/lib/Lib/Storage/StreamWrapper.php b/apps/files_external/lib/Lib/Storage/StreamWrapper.php
index dc203399646..79387e14cf6 100644
--- a/apps/files_external/lib/Lib/Storage/StreamWrapper.php
+++ b/apps/files_external/lib/Lib/Storage/StreamWrapper.php
@@ -117,8 +117,8 @@ abstract class StreamWrapper extends \OC\Files\Storage\Common {
return copy($path, $this->constructUrl($target));
}
- public function rename($path1, $path2) {
- return rename($this->constructUrl($path1), $this->constructUrl($path2));
+ public function rename($source, $target) {
+ return rename($this->constructUrl($source), $this->constructUrl($target));
}
public function stat($path) {
diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php
index cc0ee6c7c21..85b3727f4db 100644
--- a/apps/files_external/lib/Lib/Storage/Swift.php
+++ b/apps/files_external/lib/Lib/Storage/Swift.php
@@ -482,25 +482,25 @@ class Swift extends \OC\Files\Storage\Common {
}
}
- 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);
- $fileType = $this->filetype($path1);
+ $fileType = $this->filetype($source);
if ($fileType) {
// make way
- $this->unlink($path2);
+ $this->unlink($target);
}
if ($fileType === 'file') {
try {
- $source = $this->fetchObject($path1);
- $source->copy([
- 'destination' => $this->bucket . '/' . $path2
+ $sourceObject = $this->fetchObject($source);
+ $sourceObject->copy([
+ 'destination' => $this->bucket . '/' . $target
]);
// invalidate target object to force repopulation on fetch
- $this->objectCache->remove($path2);
- $this->objectCache->remove($path2 . '/');
+ $this->objectCache->remove($target);
+ $this->objectCache->remove($target . '/');
} catch (BadResponseError $e) {
\OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
@@ -510,13 +510,13 @@ class Swift extends \OC\Files\Storage\Common {
}
} elseif ($fileType === 'dir') {
try {
- $source = $this->fetchObject($path1 . '/');
- $source->copy([
- 'destination' => $this->bucket . '/' . $path2 . '/'
+ $sourceObject = $this->fetchObject($source . '/');
+ $sourceObject->copy([
+ 'destination' => $this->bucket . '/' . $target . '/'
]);
// invalidate target object to force repopulation on fetch
- $this->objectCache->remove($path2);
- $this->objectCache->remove($path2 . '/');
+ $this->objectCache->remove($target);
+ $this->objectCache->remove($target . '/');
} catch (BadResponseError $e) {
\OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
@@ -525,14 +525,14 @@ class Swift extends \OC\Files\Storage\Common {
return false;
}
- $dh = $this->opendir($path1);
+ $dh = $this->opendir($source);
while ($file = readdir($dh)) {
if (\OC\Files\Filesystem::isIgnoredDir($file)) {
continue;
}
- $source = $path1 . '/' . $file;
- $target = $path2 . '/' . $file;
+ $source = $source . '/' . $file;
+ $target = $target . '/' . $file;
$this->copy($source, $target);
}
} else {
@@ -543,22 +543,22 @@ class Swift extends \OC\Files\Storage\Common {
return true;
}
- public function rename($path1, $path2) {
- $path1 = $this->normalizePath($path1);
- $path2 = $this->normalizePath($path2);
+ public function rename($source, $target) {
+ $source = $this->normalizePath($source);
+ $target = $this->normalizePath($target);
- $fileType = $this->filetype($path1);
+ $fileType = $this->filetype($source);
if ($fileType === 'dir' || $fileType === 'file') {
// copy
- if ($this->copy($path1, $path2) === false) {
+ if ($this->copy($source, $target) === false) {
return false;
}
// cleanup
- if ($this->unlink($path1) === false) {
+ if ($this->unlink($source) === false) {
throw new \Exception('failed to remove original');
- $this->unlink($path2);
+ $this->unlink($target);
return false;
}