Better handle readdirent errors
This commit is contained in:
parent
897c4869de
commit
1a3ba9efca
|
@ -33,7 +33,7 @@ func TrackedError(err error) *RequestError {
|
||||||
// generated this server for the purposes of logging.
|
// generated this server for the purposes of logging.
|
||||||
func TrackedServerError(err error, s *server.Server) *RequestError {
|
func TrackedServerError(err error, s *server.Server) *RequestError {
|
||||||
return &RequestError{
|
return &RequestError{
|
||||||
Err: errors.WithStack(err),
|
Err: err,
|
||||||
Uuid: uuid.Must(uuid.NewRandom()).String(),
|
Uuid: uuid.Must(uuid.NewRandom()).String(),
|
||||||
Message: "",
|
Message: "",
|
||||||
server: s,
|
server: s,
|
||||||
|
|
|
@ -82,7 +82,7 @@ func getServerListDirectory(c *gin.Context) {
|
||||||
|
|
||||||
stats, err := s.Filesystem.ListDirectory(d)
|
stats, err := s.Filesystem.ListDirectory(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err.Error() == "readdirent: not a directory" {
|
if e, ok := err.(*os.SyscallError); ok && e.Syscall == "readdirent" {
|
||||||
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{
|
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{
|
||||||
"error": "The requested directory does not exist.",
|
"error": "The requested directory does not exist.",
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user