From 8d2cb51cfd3ff62bfa6652a8be40f19e4e78103c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Thu, 21 Apr 2022 11:34:07 +0200 Subject: [PATCH] Fix SFTP retry mechanism As of phpseclib v3 `RuntimeException` objects are thrown, causing the whole retry logic to be bypassed. This makes sure to re-attempt to connect when timeout or connection issues happen. --- SftpConnectionProvider.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SftpConnectionProvider.php b/SftpConnectionProvider.php index 82c1b42..995f6a7 100644 --- a/SftpConnectionProvider.php +++ b/SftpConnectionProvider.php @@ -4,6 +4,7 @@ namespace League\Flysystem\PhpseclibV3; +use League\Flysystem\FilesystemException; use phpseclib3\Crypt\Common\AsymmetricKey; use phpseclib3\Crypt\PublicKeyLoader; use phpseclib3\Exception\NoKeyLoadedException; @@ -137,7 +138,10 @@ private function setupConnection(): SFTP $this->authenticate($connection); } catch (Throwable $exception) { $connection->disconnect(); - throw $exception; + + if ($exception instanceof FilesystemException) { + throw $exception; + } } return $connection;