def check_object(start_id, repair, stats)
      @db.mark(start_id)
      # The todo list holds a touple for each object that still needs to be
      # checked. The first item is the referring object and the second is the
      # ID of the object to check.
      todo_list = [ [ nil, start_id ] ]

      while !todo_list.empty?
        # Get the next PEROBS object to check
        ref_obj, id = todo_list.pop

        begin
          obj = object_by_id(id)
        rescue PEROBS::FatalError
          obj = nil
        end

        if obj
          # The object exists and is OK. Mark is as checked.
          @db.mark(id)
          # Now look at all other objects referenced by this object.
          obj._referenced_object_ids.each do |refd_id|
            # Push them onto the todo list unless they have been marked
            # already.
            todo_list << [ obj, refd_id ] unless @db.is_marked?(refd_id, true)
          end
        else
          # Remove references to bad objects.
          if ref_obj
            if repair
              PEROBS.log.error "Removing reference to " +
                "#{obj ? 'broken' : 'non-existing'} object #{id} from:\n" +
                ref_obj.inspect
              ref_obj._delete_reference_to_id(id)
            else
              PEROBS.log.error "The following object references a " +
                "#{obj ? 'broken' : 'non-existing'} object #{id}:\n" +
                ref_obj.inspect
            end
          end
          stats[:errors] += 1
        end

        @progressmeter.update(stats[:object_cnt] += 1)
      end
    end
def check_object(start_id, repair, stats)
      @db.mark(start_id)
      # The todo list holds a touple for each object that still needs to be
      # checked. The first item is the referring object and the second is the
      # ID of the object to check.
      todo_list = [ [ nil, start_id ] ]

      while !todo_list.empty?
        # Get the next PEROBS object to check
        ref_obj, id = todo_list.pop

        begin
          obj = object_by_id(id)
        rescue PEROBS::FatalError
          obj = nil
        end

        if obj
          # The object exists and is OK. Mark is as checked.
          @db.mark(id)
          # Now look at all other objects referenced by this object.
          obj._referenced_object_ids.each do |refd_id|
            # Push them onto the todo list unless they have been marked
            # already.
            todo_list << [ obj, refd_id ] unless @db.is_marked?(refd_id, true)
          end
        else
          # Remove references to bad objects.
          if ref_obj
            if repair
              PEROBS.log.error "Removing reference to " +
                "#{obj ? 'broken' : 'non-existing'} object #{id} from:\n" +
                ref_obj.inspect
              ref_obj._delete_reference_to_id(id)
            else
              PEROBS.log.error "The following object references a " +
                "#{obj ? 'broken' : 'non-existing'} object #{id}:\n" +
                ref_obj.inspect
            end
          end
          stats[:errors] += 1
        end

        @progressmeter.update(stats[:object_cnt] += 1)
      end
    end
Check the object with the given start_id and all other objects that are
 somehow reachable from the start object.
 @param start_id [Integer] ID of the top-level object to start
        with
 @param repair [Boolean] Delete refernces to broken objects if true
 @return [Integer] The number of references to bad objects.