From ef4cf344a3574a7175071b71494b21b2d6e40411 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 8 Dec 2021 15:49:02 +0100 Subject: [PATCH] Fix delete panic --- server/fileservice.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/fileservice.go b/server/fileservice.go index d23dadd..465a93c 100644 --- a/server/fileservice.go +++ b/server/fileservice.go @@ -106,7 +106,11 @@ func (s *GRPCFileServiceServer) DeleteFile(ctx context.Context, req *pb.DeleteFi // Ensure owner of file or admin f, err := s.store.GetFile(req.Id) if err != nil { + if err == store.ErrNoSuchItem { + return nil, status.Error(codes.NotFound, "no such file") + } s.Logger.Warnw("Error getting file.", "error", err) + return nil, status.Errorf(codes.Internal, "error getting file: %s", err) } if !(f.Metadata.Owner == interceptors.UserIDFromContext(ctx) || interceptors.RoleFromContext(ctx) == pb.User_ADMIN) { return nil, status.Error(codes.PermissionDenied, "permission denied")