From 467a0d6a85339eff05d5c035c9abb587266c9bb4 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 3 Oct 2024 13:36:33 -0400 Subject: [PATCH] tools: automate: Fail early if directory can't be renamed (fixes #2502) --- tools/automate/automate-git.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/automate/automate-git.py b/tools/automate/automate-git.py index c3d8efad5..143900d88 100644 --- a/tools/automate/automate-git.py +++ b/tools/automate/automate-git.py @@ -117,7 +117,13 @@ def move_directory(source, target, allow_overwrite=False): if os.path.exists(source): msg("Moving directory %s to %s" % (source, target)) if not options.dryrun: - shutil.move(source, target) + try: + # This will fail if |source| and |target| are on different filesystems, + # or if files in |source| are currently locked. + os.rename(source, target) + except OSError: + msg('ERROR Failed to move directory %s to %s' % (source, target)) + raise def is_git_checkout(path):