Fix delete panic

This commit is contained in:
Torjus Håkestad 2021-12-08 15:49:02 +01:00
parent 9b21e1f0cb
commit ef4cf344a3

View File

@ -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")