Skip to content

Commit

Permalink
Merge pull request #1451 from lcobucci/fix-sftp-retries
Browse files Browse the repository at this point in the history
Fix SFTP retry mechanism
  • Loading branch information
frankdejonge committed Apr 21, 2022
2 parents 837431d + b0b5a52 commit 8ce6dd9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/PhpseclibV3/SftpConnectionProvider.php
Expand Up @@ -4,12 +4,12 @@

namespace League\Flysystem\PhpseclibV3;

use League\Flysystem\FilesystemException;
use phpseclib3\Crypt\Common\AsymmetricKey;
use phpseclib3\Crypt\PublicKeyLoader;
use phpseclib3\Exception\NoKeyLoadedException;
use phpseclib3\Net\SFTP;
use phpseclib3\System\SSH\Agent;
use RuntimeException;
use Throwable;

use function base64_decode;
Expand Down Expand Up @@ -138,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 Expand Up @@ -229,8 +232,6 @@ private function loadPrivateKey(): AsymmetricKey
} catch (NoKeyLoadedException $exception) {
throw new UnableToLoadPrivateKey();
}

throw new RuntimeException();
}

private function authenticateWithAgent(SFTP $connection): void
Expand Down

0 comments on commit 8ce6dd9

Please sign in to comment.