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