From 47d41e8ddd7c19161167eef702c62c6c3e17609d Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Sat, 4 Feb 2017 12:24:16 +0100 Subject: [PATCH] Switch to UTF-8 after login closes #72 --- ftp.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ftp.go b/ftp.go index 8b43bcd..5334a44 100644 --- a/ftp.go +++ b/ftp.go @@ -95,12 +95,6 @@ func DialTimeout(addr string, timeout time.Duration) (*ServerConn, error) { return nil, err } - err = c.setUTF8() - if err != nil { - c.Quit() - return nil, err - } - if _, mlstSupported := c.features["MLST"]; mlstSupported { c.mlstSupported = true } @@ -130,8 +124,12 @@ func (c *ServerConn) Login(user, password string) error { } // Switch to binary mode - _, _, err = c.cmd(StatusCommandOK, "TYPE I") - if err != nil { + if _, _, err = c.cmd(StatusCommandOK, "TYPE I"); err != nil { + return err + } + + // Switch to UTF-8 + if err := c.setUTF8(); err != nil { return err }