aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNigel Tao <nigeltao@golang.org>2015-02-04 12:23:13 +1100
committerNigel Tao <nigeltao@golang.org>2015-02-04 02:05:37 +0000
commit1cd7b7179478daf1f19f8b4b4f08106ef411619b (patch)
tree201c4290921756da242bff35c22016bcf1fc0944
parent5feaa29a7b94c0462cfd22c1aa7f3907c7eeec00 (diff)
downloadnet-1cd7b7179478daf1f19f8b4b4f08106ef411619b.tar.gz
webdav: return 500 Internal Server Error and not 404 Not Found or 403
Forbidden during copyFiles. Change-Id: Ica2df08e1e4086c0c6db5a4c90bcf4fefc850bc7 Reviewed-on: https://go-review.googlesource.com/3835 Reviewed-by: Dave Cheney <dave@cheney.net>
-rw-r--r--webdav/file.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/webdav/file.go b/webdav/file.go
index 4069f24..0f67853 100644
--- a/webdav/file.go
+++ b/webdav/file.go
@@ -562,12 +562,18 @@ func copyFiles(fs FileSystem, src, dst string, overwrite bool, depth int, recurs
srcFile, err := fs.OpenFile(src, os.O_RDONLY, 0)
if err != nil {
- return http.StatusNotFound, err
+ if os.IsNotExist(err) {
+ return http.StatusNotFound, err
+ }
+ return http.StatusInternalServerError, err
}
defer srcFile.Close()
srcStat, err := srcFile.Stat()
if err != nil {
- return http.StatusNotFound, err
+ if os.IsNotExist(err) {
+ return http.StatusNotFound, err
+ }
+ return http.StatusInternalServerError, err
}
srcPerm := srcStat.Mode() & os.ModePerm
@@ -620,10 +626,10 @@ func copyFiles(fs FileSystem, src, dst string, overwrite bool, depth int, recurs
_, copyErr := io.Copy(dstFile, srcFile)
closeErr := dstFile.Close()
if copyErr != nil {
- return http.StatusForbidden, copyErr
+ return http.StatusInternalServerError, copyErr
}
if closeErr != nil {
- return http.StatusForbidden, closeErr
+ return http.StatusInternalServerError, closeErr
}
}