Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SFTP retry mechanism #1451

Merged
merged 2 commits into from
Apr 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/PhpseclibV3/SftpConnectionProvider.php
Original file line number Diff line number Diff line change
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