Skip to content

Commit 8b7a028

Browse files
overwrite file, don't mv to avoid rm
1 parent 652d419 commit 8b7a028

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Types.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ function write_env_usage(source_file::AbstractString, usage_filepath::AbstractSt
477477
TOML.parsefile(usage_file)
478478
catch
479479
retries += 1
480-
retries > 20 && rethrow()
480+
retries > 5 && rethrow()
481481
sleep(0.1)
482482
@goto retry1
483483
end
@@ -500,8 +500,10 @@ function write_env_usage(source_file::AbstractString, usage_filepath::AbstractSt
500500
TOML.print(io, usage, sorted=true)
501501
end
502502

503-
# Move the temp file into place, replacing the original
504-
mv(temp_usage_file, usage_file, force = true)
503+
# Create or overwrite the original (this is as fast as mv, but doesn't rm the original to overwrite)
504+
open(usage_file, "w") do io
505+
write(io, read(temp_usage_file, String))
506+
end
505507

506508
# Check that the new file has what we want in it
507509
new_usage = if isfile(usage_file)
@@ -512,7 +514,7 @@ function write_env_usage(source_file::AbstractString, usage_filepath::AbstractSt
512514
TOML.parsefile(usage_file)
513515
catch
514516
retries += 1
515-
retries > 20 && rethrow()
517+
retries > 5 && rethrow()
516518
sleep(0.1)
517519
@goto retry2
518520
end

0 commit comments

Comments
 (0)