From f4865334aecbffa2c3a11af77ff0bee8ba956f41 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Thu, 30 Mar 2023 15:35:25 -0700 Subject: [PATCH] avoid writing the same view multiple times in exchange mode --- lib/spack/spack/environment/environment.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py index 3be877b54b0..299cc1f59f0 100644 --- a/lib/spack/spack/environment/environment.py +++ b/lib/spack/spack/environment/environment.py @@ -692,6 +692,13 @@ def regenerate(self, concretized_root_specs, force=False): if update_method == "exchange": if os.path.isdir(new_root): + # 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) + return shutil.rmtree(new_root) _error_on_nonempty_view_dir(new_root)