ftp: fix error in dir() (#8504)

pull/8511/head
yuyi 2021-02-02 15:22:52 +08:00 committed by GitHub
parent 9a2820fa7b
commit 5ec6f7a781
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -67,7 +67,9 @@ mut:
}
pub fn new() FTP {
mut f := FTP{ conn: 0 }
mut f := FTP{
conn: 0
}
f.buffer_size = 1024
return f
}
@ -178,7 +180,7 @@ fn new_dtp(msg string) ?&DTP {
mut dtp := &DTP{
ip: ip
port: port
conn: 0
conn: 0
}
conn := net.dial_tcp('$ip:$port') or { return error('Cannot connect to the data channel') }
dtp.conn = conn
@ -220,7 +222,7 @@ pub fn (mut zftp FTP) dir() ?[]string {
for lfile in sdir.split('\n') {
if lfile.len > 1 {
spl := lfile.split(' ')
dir << spl[spl.len - 1]
dir << spl[spl.len - 1].trim_space()
}
}
return dir

View File

@ -7,13 +7,13 @@ fn test_ftp_cleint() {
// NB: this function makes network calls to external servers,
// that is why it is not a very good idea to run it in CI.
// If you want to run it manually, use:
// `v -d network vlib/net/ftp/ftp_test.v`
// `v -d network vlib/net/ftp/ftp_test.v`
ftp_client_test_inside() or { panic(err) }
}
fn ftp_client_test_inside() ? {
mut zftp := ftp.new()
// eprintln(zftp)
// eprintln(zftp)
defer {
zftp.close() or { panic(err) }
}
@ -41,6 +41,7 @@ fn ftp_client_test_inside() ? {
return
}
assert dir_list2.len > 0
assert dir_list2.contains('katello-host-tools-3.3.5-8.sles11_4sat.src.rpm')
blob := zftp.get('katello-host-tools-3.3.5-8.sles11_4sat.src.rpm') or {
assert false
return