Merge pull request #73 from digineo/move-utf8

Switch to UTF-8 after login
This commit is contained in:
Julien Laffaye 2017-02-05 20:45:42 +01:00 committed by GitHub
commit 4596ddad4d

14
ftp.go
View File

@ -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
}