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

make saving remotes file transactional #17588

Open
wants to merge 1 commit into
base: develop2
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion conan/api/subapi/remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ def _save(remotes_file, remotes):
if r.remote_type:
remote["remote_type"] = r.remote_type
remote_list.append(remote)
save(remotes_file, json.dumps({"remotes": remote_list}, indent=True))
# This atomic replace avoids a corrupted remotes.json file if this is killed during the process
save(remotes_file + ".tmp", json.dumps({"remotes": remote_list}, indent=True))
os.replace(remotes_file + ".tmp", remotes_file)


def _filter(remotes, pattern, only_enabled=True):
Expand Down
Loading