From 5acf4492c118385257c86fd8e71e112b46966869 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Sat, 19 Oct 2024 01:38:19 +0000 Subject: [PATCH] project: add west init --rename-delay-hack This will be useful as both a diagnostic tool and as a workaround; see October 2024 comments in west issue #558 for examples and details. Signed-off-by: Marc Herbert --- src/west/app/project.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/west/app/project.py b/src/west/app/project.py index f3caf66c..6104844d 100644 --- a/src/west/app/project.py +++ b/src/west/app/project.py @@ -16,6 +16,7 @@ import subprocess import sys import textwrap +import time from time import perf_counter from urllib.parse import urlparse @@ -163,8 +164,12 @@ def __init__(self): Visual Studio Code before running 'west init` on the Windows NTFS filesystem. Find other, similar "Access is denied" examples in west issue #558. -This is not required on inode-based, Linux filesystems that wait and +This is not required with most Linux filesystems that have an inode +indirection layer and can wait to finalize the deletion until there is no concurrent user left. +If you cannot identify or cannot stop the background scanner +that is interfering with renames on your system, try the --rename-delay hack +below. ''', requires_workspace=False) @@ -201,6 +206,12 @@ def do_add_parser(self, parser_adder): MANIFEST_URL; .west is created next to "directory" in this case, and manifest.path points at "directory"''') + parser.add_argument('--rename-delay', type=int, + help='''Number of seconds to wait before renaming + some temporary directories. Some filesystems like NTFS + cannot rename files in use; see above. This is a HACK + that may or may not give enough time for some random + background scanner to complete. ''') parser.add_argument( 'directory', nargs='?', default=None, @@ -339,6 +350,13 @@ def bootstrap(self, args) -> Path: manifest_abspath = topdir / manifest_path + # Some filesystems like NTFS can't rename files in use. + # See west issue #558. Will ReFS address this? + ren_delay = args.rename_delay + if ren_delay is not None: + self.inf(f"HACK: waiting {ren_delay} seconds before renaming {tempdir}") + time.sleep(ren_delay) + self.dbg('moving', tempdir, 'to', manifest_abspath, level=Verbosity.DBG_EXTREME)