You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
client.MkdirAll not returning an error when docs state it should #609
Hi, I am just making a project learning about sftp and transferring data, anyways, I am making a directory, creating a file within it, and then extending that file directory by one. According to the docs of MkdirAll it says:
MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. If path is already a directory, MkdirAll does nothing and returns nil. If path contains a regular file, an error is returned
however nil is still received back in the code below
// connect to ssh serverconn, err:=ssh.Dial("tcp", sshAddr, config)
iferr!=nil {
log.Fatal("Failed to dial: ", err)
}
deferconn.Close()
// open an SFTP session over an existing ssh connection.client, err:=sftp.NewClient(conn)
iferr!=nil {
log.Fatal(err)
}
deferclient.Close()
varuser="USER"varsftpBasePath=fmt.Sprintf("home/%s", user)
err=client.MkdirAll(sftpBasePath)
iferr!=nil {
log.Fatal(err)
}
// leave your markf, err:=client.Create(fmt.Sprintf("%s/hello.txt", sftpBasePath))
iferr!=nil {
log.Fatal(err)
}
if_, err:=f.Write([]byte("Hello world!")); err!=nil {
log.Fatal(err)
}
// error should be returned below as there is a ".txt"// file in the path before creating the `dir` directoryerr=client.MkdirAll(sftpBasePath+"/dir")
iferr!=nil {
log.Fatal(err)
}
f.Close()
I should also mention that the ssh server when I inspect the documents the file is created at that path and the dir directory
I figured out what was meant in the raising of this issue, and looking at it, the language does indeed appear to be ambiguous. If you could check the PR #611 and confirm or not whether it is more clear, then we can resolve this issue.
Activity
puellanivis commentedon Dec 20, 2024
The order of commands that you give should not yield any errors. It simply creates a
dirnext tohello.txt:Issue #609 - clarify what 'path contains a regular file' actually means
puellanivis commentedon Dec 30, 2024
I figured out what was meant in the raising of this issue, and looking at it, the language does indeed appear to be ambiguous. If you could check the PR #611 and confirm or not whether it is more clear, then we can resolve this issue.
Merge pull request #611 from pkg/ISSUE-609-clarify-mkdirall-error-con…