Skip to content

Commit

Permalink
project: add west init --rename-delay-hack
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
marc-hb committed Oct 19, 2024
1 parent c3aadf5 commit 88affcc
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import subprocess
import sys
import textwrap
import time
from time import perf_counter
from urllib.parse import urlparse

Expand Down Expand Up @@ -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
workaround below.
''',
requires_workspace=False)

Expand Down Expand Up @@ -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-hack', 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,
Expand Down Expand Up @@ -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_hack
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)

Expand Down

0 comments on commit 88affcc

Please sign in to comment.