improved way to find oldest file in dir
This commit is contained in:
parent
fec8a6dace
commit
7904d2f13a
@ -691,9 +691,8 @@ def regenerate(self, concretized_root_specs, force=False):
|
||||
# If new_root is the newest thing in its directory, no need to update
|
||||
parent = os.path.dirname(new_root)
|
||||
siblings = [os.path.join(parent, s) for s in os.listdir(parent)]
|
||||
siblings.sort(reverse=True, key=lambda p: os.stat(p).st_mtime)
|
||||
if siblings[0] == new_root:
|
||||
tty.debug("View at %s does not need regenration." % self.root)
|
||||
if max(siblings, key=lambda p: os.stat(p).st_mtime) == new_root:
|
||||
tty.debug("View at %s does not need regeneration." % self.root)
|
||||
return
|
||||
shutil.rmtree(new_root)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user