summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-08-29 19:47:24 +0200
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2023-09-18 17:33:42 +0000
commit70658918d918027c4f6b1e4529ccd93cdd71c75e (patch)
tree6b201fa65dd259087ffdce23421fc239c480bec7
parent42ed302c012a222ffe8cade7ee919a05b7357e20 (diff)
downloadnextcloud-server-70658918d918027c4f6b1e4529ccd93cdd71c75e.tar.gz
nextcloud-server-70658918d918027c4f6b1e4529ccd93cdd71c75e.zip
clear sftp stat cache when opening a write stream
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--apps/files_external/lib/Lib/Storage/SFTP.php8
1 files changed, 5 insertions, 3 deletions
diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php
index e46f60d0be4..e2f8480756c 100644
--- a/apps/files_external/lib/Lib/Storage/SFTP.php
+++ b/apps/files_external/lib/Lib/Storage/SFTP.php
@@ -370,6 +370,7 @@ class SFTP extends \OC\Files\Storage\Common {
public function fopen($path, $mode) {
try {
$absPath = $this->absPath($path);
+ $connection = $this->getConnection();
switch ($mode) {
case 'r':
case 'rb':
@@ -377,13 +378,14 @@ class SFTP extends \OC\Files\Storage\Common {
return false;
}
SFTPReadStream::register();
- $context = stream_context_create(['sftp' => ['session' => $this->getConnection()]]);
+ $context = stream_context_create(['sftp' => ['session' => $connection]]);
$handle = fopen('sftpread://' . trim($absPath, '/'), 'r', false, $context);
return RetryWrapper::wrap($handle);
case 'w':
case 'wb':
SFTPWriteStream::register();
- $context = stream_context_create(['sftp' => ['session' => $this->getConnection()]]);
+ $connection->_remove_from_stat_cache($absPath);
+ $context = stream_context_create(['sftp' => ['session' => $connection]]);
return fopen('sftpwrite://' . trim($absPath, '/'), 'w', false, $context);
case 'a':
case 'ab':
@@ -395,7 +397,7 @@ class SFTP extends \OC\Files\Storage\Common {
case 'x+':
case 'c':
case 'c+':
- $context = stream_context_create(['sftp' => ['session' => $this->getConnection()]]);
+ $context = stream_context_create(['sftp' => ['session' => $connection]]);
$handle = fopen($this->constructUrl($path), $mode, false, $context);
return RetryWrapper::wrap($handle);
}