Skip to content

Commit b98ae1a

Browse files
author
Arin Ghazarian
committed
Dispose the private key
1 parent 052fa1a commit b98ae1a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/bbs2gh/Services/BbsSshArchiveDownloader.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public sealed class BbsSshArchiveDownloader : IBbsArchiveDownloader, IDisposable
1212
private const int DOWNLOAD_PROGRESS_REPORT_INTERVAL_IN_SECONDS = 10;
1313

1414
private readonly ISftpClient _sftpClient;
15+
private readonly PrivateKeyFile _privateKey;
1516
private readonly OctoLogger _log;
1617
private readonly FileSystemProvider _fileSystemProvider;
1718
private readonly object _mutex = new();
@@ -21,7 +22,8 @@ public BbsSshArchiveDownloader(OctoLogger log, FileSystemProvider fileSystemProv
2122
{
2223
_log = log;
2324
_fileSystemProvider = fileSystemProvider;
24-
_sftpClient = new SftpClient(host, sshPort, sshUser, new PrivateKeyFile(privateKeyFileFullPath));
25+
_privateKey = new PrivateKeyFile(privateKeyFileFullPath);
26+
_sftpClient = new SftpClient(host, sshPort, sshUser, _privateKey);
2527
}
2628

2729
internal BbsSshArchiveDownloader(OctoLogger log, FileSystemProvider fileSystemProvider, ISftpClient sftpClient)
@@ -120,5 +122,6 @@ private string GetLogFriendlySize(ulong size)
120122
public void Dispose()
121123
{
122124
_sftpClient?.Dispose();
125+
_privateKey?.Dispose();
123126
}
124127
}

0 commit comments

Comments
 (0)