Fix delete panic
This commit is contained in:
parent
9b21e1f0cb
commit
ef4cf344a3
@ -106,7 +106,11 @@ func (s *GRPCFileServiceServer) DeleteFile(ctx context.Context, req *pb.DeleteFi
|
|||||||
// Ensure owner of file or admin
|
// Ensure owner of file or admin
|
||||||
f, err := s.store.GetFile(req.Id)
|
f, err := s.store.GetFile(req.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if err == store.ErrNoSuchItem {
|
||||||
|
return nil, status.Error(codes.NotFound, "no such file")
|
||||||
|
}
|
||||||
s.Logger.Warnw("Error getting file.", "error", err)
|
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) {
|
if !(f.Metadata.Owner == interceptors.UserIDFromContext(ctx) || interceptors.RoleFromContext(ctx) == pb.User_ADMIN) {
|
||||||
return nil, status.Error(codes.PermissionDenied, "permission denied")
|
return nil, status.Error(codes.PermissionDenied, "permission denied")
|
||||||
|
Loading…
Reference in New Issue
Block a user