Improve Error Handling (#54)
* bubble up request errors [#28]
* inhibit stream close on request
* add `StatusError`
* `PUT`: check if given target is a directory
* Revert "inhibit stream close on request"
Cherry-picked into branch dev-bodyclosing.
This reverts commit 2889239999.
Co-authored-by: Christoph Polcin <coco@miconoco.de>
This commit is contained in:
@@ -4,13 +4,16 @@ import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
d "github.com/studio-b12/gowebdav"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
d "github.com/studio-b12/gowebdav"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -190,8 +193,18 @@ func cmdCp(c *d.Client, p0, p1 string) (err error) {
|
||||
|
||||
func cmdPut(c *d.Client, p0, p1 string) (err error) {
|
||||
if p1 == "" {
|
||||
p1 = filepath.Join(".", p0)
|
||||
p1 = path.Join(".", p0)
|
||||
} else {
|
||||
var fi fs.FileInfo
|
||||
fi, err = c.Stat(p0)
|
||||
if err != nil && !d.IsErrNotFound(err) {
|
||||
return
|
||||
}
|
||||
if !d.IsErrNotFound(err) && fi.IsDir() {
|
||||
p0 = path.Join(p0, p1)
|
||||
}
|
||||
}
|
||||
|
||||
stream, err := getStream(p1)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user