lib/perobs/FlatFileBlobHeader.rb in perobs-3.0.1 vs lib/perobs/FlatFileBlobHeader.rb in perobs-3.0.2

- old
+ new

@@ -57,14 +57,14 @@ attr_reader :addr, :flags, :length, :id, :crc # Create a new FlatFileBlobHeader with the given flags, length, id and crc. # @param file [File] the FlatFile that contains the header # @param addr [Integer] the offset address of the header in the file - # @param flags [Fixnum] 8 bit number, see above - # @param length [Fixnum] length of the header in bytes + # @param flags [Integer] 8 bit number, see above + # @param length [Integer] length of the header in bytes # @param id [Integer] ID of the blob entry - # @param crc [Fixnum] CRC32 checksum of the blob entry + # @param crc [Integer] CRC32 checksum of the blob entry def initialize(file, addr, flags, length, id, crc) @file = file @addr = addr @flags = flags @length = length @@ -114,11 +114,12 @@ "#{addr}" end header = FlatFileBlobHeader.new(file, addr, *buf.unpack(FORMAT)) if id && header.id != id PEROBS.log.fatal "Mismatch between FlatFile index and blob file " + - "found for entry with ID #{id}/#{header.id}" + "found. FlatFile has entry with ID #{header.id} at address " + + "#{addr}. Index has ID #{id} for this address." end return header end @@ -136,17 +137,11 @@ # Reset all the flags bit to 0. This marks the blob as invalid. # @param file [File] The file handle of the blob file. # @param addr [Integer] The address of the header def clear_flags - begin - @file.seek(@addr) - @file.write([ 0 ].pack('C')) - @file.flush - rescue IOError => e - PEROBS.log.fatal "Clearing flags of FlatFileBlobHeader with ID " + - "#{@id} failed: #{e.message}" - end + @flags = 0 + write_flags end # Return true if the header is for a non-empty blob. def is_valid? bit_set?(VALID_FLAG_BIT)