Browse Source

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>

Nigel Tao 11 years ago
parent
commit
1cd7b71794
1 changed files with 10 additions and 4 deletions
  1. 10 4
      webdav/file.go

+ 10 - 4
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
 		}
 	}