From 7edcdbfcc512d423e185395bf58372fe21fbdf2a Mon Sep 17 00:00:00 2001 From: Eric Faurot Date: Thu, 11 Jun 2026 21:32:26 +0200 Subject: [PATCH] Properly close the sftp client in importer/exporter/storage Close() method. Also close the local client in storage.Ping(). This makes sure the underlying ssh process is stopped and Wait()'ed before the main process exits. Fixes zombie issues. --- sftp/exporter/sftp.go | 2 +- sftp/importer/sftp.go | 2 +- sftp/storage/sftp.go | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sftp/exporter/sftp.go b/sftp/exporter/sftp.go index afe1225..bd7aa1f 100644 --- a/sftp/exporter/sftp.go +++ b/sftp/exporter/sftp.go @@ -106,7 +106,7 @@ func (p *Exporter) Ping(ctx context.Context) error { } func (p *Exporter) Close(ctx context.Context) error { - return nil + return p.client.Close() } type dirPerm struct { diff --git a/sftp/importer/sftp.go b/sftp/importer/sftp.go index 294c5ea..67ee935 100644 --- a/sftp/importer/sftp.go +++ b/sftp/importer/sftp.go @@ -204,5 +204,5 @@ func (p *Importer) Ping(ctx context.Context) error { } func (p *Importer) Close(ctx context.Context) error { - return nil + return p.client.Close() } diff --git a/sftp/storage/sftp.go b/sftp/storage/sftp.go index 293780b..9d1c018 100644 --- a/sftp/storage/sftp.go +++ b/sftp/storage/sftp.go @@ -108,6 +108,7 @@ func (s *Store) Ping(ctx context.Context) error { if err != nil { return err } + defer client.Close() _, err = client.Lstat(s.endpoint.Path) return err @@ -269,7 +270,7 @@ func (s *Store) Size(ctx context.Context) (int64, error) { } func (s *Store) Close(ctx context.Context) error { - return nil + return s.client.Close() } /* Locks */