This commit is contained in:
Gregory Becker 2023-03-29 13:04:17 -07:00
parent b8e58e9bd8
commit b48dfe6589
3 changed files with 4 additions and 6 deletions

View File

@ -425,7 +425,7 @@ def env_view_setup_parser(subparser):
"--force",
action="store_true",
dest="force",
help="regenerate even if regeneration cannot be done atomically"
help="regenerate even if regeneration cannot be done atomically",
)
subparser.add_argument(
"action", choices=ViewAction.actions(), help="action to take for the environment's view"

View File

@ -626,11 +626,8 @@ def raise_if_symlink_before_exchange(self, force):
def raise_if_exchange_before_symlink(self, force):
if os.path.isdir(self.root) and not os.path.islink(self.root):
if force:
try:
shutil.rmtree(self.root)
return
except:
pass
shutil.rmtree(self.root, ignore_errors=True)
return
msg = f"The view at {self.root} cannot be updated with the 'symlink' update method"
msg += " because it was originally constructed with the 'exchange' method."
msg += "\n Either change the update method to 'exchange' or"

View File

@ -3329,6 +3329,7 @@ def test_view_update_mismatch(update_method, tmpdir, install_mockery, mock_fetch
view.regenerate([spec], force=True)
assert os.path.exists(view.root)
@pytest.mark.parametrize("update_method", ["symlink", "exchange"])
def test_view_update_fails(update_method, tmpdir, install_mockery, mock_fetch, monkeypatch):
root = str(tmpdir.join("root"))