1
mirror of https://github.com/rclone/rclone synced 2024-12-27 19:43:48 +01:00

smb: code cleanup to avoid overwriting ctx before first use (fixes issue reported by the staticcheck linter)

This commit is contained in:
albertony 2023-03-25 23:22:08 +01:00
parent 155f4f2e21
commit 270af61665

View File

@ -106,9 +106,9 @@ func (f *Fs) getSessions() int32 {
func (f *Fs) newConnection(ctx context.Context, share string) (c *conn, err error) {
// As we are pooling these connections we need to decouple
// them from the current context
ctx = context.Background()
bgCtx := context.Background()
c, err = f.dial(ctx, "tcp", f.opt.Host+":"+f.opt.Port)
c, err = f.dial(bgCtx, "tcp", f.opt.Host+":"+f.opt.Port)
if err != nil {
return nil, fmt.Errorf("couldn't connect SMB: %w", err)
}
@ -119,7 +119,7 @@ func (f *Fs) newConnection(ctx context.Context, share string) (c *conn, err erro
_ = c.smbSession.Logoff()
return nil, fmt.Errorf("couldn't initialize SMB: %w", err)
}
c.smbShare = c.smbShare.WithContext(ctx)
c.smbShare = c.smbShare.WithContext(bgCtx)
}
return c, nil
}