From 7904d2f13acafb6db82dbb80c1ef28ca8152dd10 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Mon, 3 Apr 2023 13:55:18 -0700 Subject: [PATCH] improved way to find oldest file in dir --- lib/spack/spack/environment/environment.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py index 31a60b4d741..e34cffb3beb 100644 --- a/lib/spack/spack/environment/environment.py +++ b/lib/spack/spack/environment/environment.py @@ -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)