lib/perobs/BTreeBlob.rb in perobs-2.0.1 vs lib/perobs/BTreeBlob.rb in perobs-2.1.0

- old
+ new

@@ -1,10 +1,10 @@ # encoding: UTF-8 # # = BTreeBlob.rb -- Persistent Ruby Object Store # -# Copyright (c) 2015 by Chris Schlaeger <chris@taskjuggler.org> +# Copyright (c) 2015, 2016 by Chris Schlaeger <chris@taskjuggler.org> # # MIT License # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -135,15 +135,26 @@ raise ArgumentError, "Cannot find an entry for ID #{'%016X' % id} to check" end # Remove all entries from the index that have not been marked. + # @return [Array] List of deleted object IDs. def delete_unmarked_entries + deleted_ids = [] # First remove the entry from the hash table. - @entries_by_id.delete_if { |id, e| e[MARKED] == 0 } + @entries_by_id.delete_if do |id, e| + if e[MARKED] == 0 + deleted_ids << id + true + else + false + end + end # Then delete the entry itself. @entries.delete_if { |e| e[MARKED] == 0 } write_index + + deleted_ids end # Run a basic consistency check. # @param repair [TrueClass/FalseClass] Not used right now # @return [TrueClass/FalseClass] Always true right now