Skip to content

Commit

Permalink
Fix SFTP retry mechanism
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lcobucci committed Apr 21, 2022
1 parent cb58d3e commit b0b5a52
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/PhpseclibV3/SftpConnectionProvider.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b0b5a52

Please sign in to comment.