Skip to content

Commit

Permalink
Merge pull request #443 from mmeisinger/fix1654_dir2_m
Browse files Browse the repository at this point in the history
OOIION-1654: Fix overly restrictive directory cleanup restriction
  • Loading branch information
Jamie Chen committed Jan 7, 2014
2 parents ca030f4 + 92a5fc5 commit 00dfd13
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pyon/ion/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ def _cleanup_outdated_entries(self, dir_entries, common="key"):
"""
This function takes all DirEntry from the list and removes all but the most recent one
by ts_updated timestamp. It returns the most recent DirEntry and removes the others by
direct datastore operations.
direct datastore operations. If there are multiple entries with most recent timestamp, the
first encountered is kept and the others non-deterministically removed.
Note: This operation can be called for DirEntries without common keys, e.g. for all
entries registering an agent for a device.
"""
if not dir_entries:
return
Expand All @@ -133,9 +136,6 @@ def _cleanup_outdated_entries(self, dir_entries, common="key"):
for de in dir_entries:
if int(de.ts_updated) > int(newest_entry.ts_updated):
newest_entry = de
if de.key != newest_entry.key:
log.error("_cleanup_outdated_entries does not support different keys: %s", dir_entries)
return newest_entry

remove_list = [de for de in dir_entries if de is not newest_entry]

Expand Down

0 comments on commit 00dfd13

Please sign in to comment.