Skip to content

Commit

Permalink
Use atomic file operation to unlink file (#336)
Browse files Browse the repository at this point in the history
Fix `Lint/NonAtomicFileOperation` unsafe offense

`FileUtils.rm_f` is an alias of `FileUtils.safe_unlink`
  • Loading branch information
tagliala authored Jan 30, 2025
1 parent 9fb74a2 commit 583f31c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions .rubocop_todo.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def set_current(version)
raise InvalidVersion.new unless /^v\d+$/.match?(version)

# need to do this, or ln_s will put the symlink *into* the old dir
File.unlink directory + CURRENT if File.exist? directory + CURRENT
FileUtils.rm_f directory + CURRENT
FileUtils.ln_s version, directory + CURRENT, force: true
end

Expand Down

0 comments on commit 583f31c

Please sign in to comment.