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

Use atomic_write instead of deleting and writing file. #7889

Merged
merged 1 commit into from Jul 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions Library/Homebrew/commands.rb
Expand Up @@ -148,16 +148,14 @@ def rebuild_internal_commands_completion_list
cmds = internal_commands + internal_developer_commands + internal_commands_aliases

file = HOMEBREW_REPOSITORY/"completions/internal_commands_list.txt"
file.delete if file.exist?
file.write(cmds.sort.join("\n") + "\n")
file.atomic_write(cmds.sort.join("\n") + "\n")
end

def rebuild_commands_completion_list
# Ensure that the cache exists so we can build the commands list
HOMEBREW_CACHE.mkpath

file = HOMEBREW_CACHE/"all_commands_list.txt"
file.delete if file.exist?
file.write(commands(aliases: true).sort.join("\n") + "\n")
file.atomic_write(commands(aliases: true).sort.join("\n") + "\n")
end
end