Skip to content

Commit

Permalink
Use native file mode when possible
Browse files Browse the repository at this point in the history
`a` is native, but `W` "invented" here. No writing is done to the file,
it's only maybe truncated.
  • Loading branch information
carlhoerberg committed Aug 5, 2023
1 parent 0c7f55c commit f7d2835
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lavinmq/queue/message_store.cr
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ module LavinMQ
next unless child.starts_with? "acks."
seg = child[5, 10].to_u32
acked = Array(UInt32).new
File.open(File.join(@data_dir, child), "W+") do |file|
File.open(File.join(@data_dir, child), "a+") do |file|
loop do
pos = UInt32.from_io(file, IO::ByteFormat::SystemEndian)
if pos.zero? # pos 0 doesn't exists (first valid is 4), must be a sparse file
Expand Down

0 comments on commit f7d2835

Please sign in to comment.