Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

west manifest: detect when target directory already exists, and fail #676

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,15 @@ def bootstrap(self, args) -> Path:

self.dbg('moving', tempdir, 'to', manifest_abspath,
level=Verbosity.DBG_EXTREME)

# As shutil.move() is used to relocate tempdir, if manifest_abspath
# is an existing directory, tmpdir will be moved _inside_ it, instead
# of _to_ that path - this must be avoided. If manifest_abspath exists
# but is not a directory, then semantics depend on os.rename(), so
# avoid that too...
if manifest_abspath.exists():
self.die(f'target directory already exists ({manifest_abspath})')

manifest_abspath.parent.mkdir(parents=True, exist_ok=True)
try:
shutil.move(os.fspath(tempdir), os.fspath(manifest_abspath))
Expand Down
Loading