lib/perobs/FlatFile.rb in perobs-4.3.0 vs lib/perobs/FlatFile.rb in perobs-4.4.0

- old
+ new

@@ -219,10 +219,11 @@ end flags = 1 << FlatFileBlobHeader::VALID_FLAG_BIT flags |= (1 << FlatFileBlobHeader::COMPRESSED_FLAG_BIT) if compressed FlatFileBlobHeader.new(@f, addr, flags, raw_obj_bytesize, id, crc).write @f.write(raw_obj) + @f.flush if length != -1 && raw_obj_bytesize < length # The new object was not appended and it did not completely fill the # free space. So we have to write a new header to mark the remaining # empty space. unless length - raw_obj_bytesize >= FlatFileBlobHeader::LENGTH @@ -245,16 +246,15 @@ if old_addr # If we had an existing object stored for the ID we have to mark # this entry as deleted now. old_header.clear_flags + @f.flush # And register the newly freed space with the space list. if @space_list.is_open? @space_list.add_space(old_addr, old_header.length) end - else - @f.flush end rescue IOError => e PEROBS.log.fatal "Cannot write blob for ID #{id} to FlatFileDB: " + e.message end @@ -353,11 +353,11 @@ deleted_blobs = 0 corrupted_blobs = 0 valid_blobs = 0 # Iterate over all entries. - @progressmeter.start('Defragmentizing blobs file', @f.size) do |pm| + @progressmeter.start('Defragmenting blobs file', @f.size) do |pm| each_blob_header do |header| # If we have stumbled over a corrupted blob we treat it similar to a # deleted blob and reuse the space. if header.corruption_start distance += header.addr - header.corruption_start @@ -576,10 +576,9 @@ end # Repair the FlatFile. In contrast to the repair functionality in the # check() method this method is much faster. It simply re-creates the # index and space list from the blob file. - # @param repair [Boolean] True if errors should be fixed. # @return [Integer] Number of errors found def repair errors = 0 return errors unless @f