Merge pull request 'Fix delete panic' (#27) from 26-delete-panic into master
Reviewed-on: https://gitea.benny.dog/torjus/ezshare/pulls/27
This commit is contained in:
commit
2f7676b35e
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user