Skip to content

Commit

Permalink
[FileWatching.Pidfile] on Windows, we should rename a file before we …
Browse files Browse the repository at this point in the history
…delete it (#44984)

Convert several occurrences of `rm` to `tryrmopenfile`
  • Loading branch information
DilumAluthge authored Apr 20, 2022
1 parent d90316e commit c874cdb
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions stdlib/FileWatching/src/pidfile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mutable struct LockMonitor
lock = new(at, fd, update)
finalizer(close, lock)
catch ex
rm(at)
tryrmopenfile(at)
close(fd)
rethrow(ex)
end
Expand Down Expand Up @@ -280,7 +280,7 @@ function tryrmopenfile(path::String)
true
catch ex
isa(ex, IOError) || rethrow(ex)
false
ex
end
end

Expand All @@ -306,13 +306,7 @@ function Base.close(lock::LockMonitor)
end
if pathstat !== nothing && samefile(stat(lock.fd), pathstat)
# try not to delete someone else's lock
try
rm(path)
removed = true
catch ex
ex isa IOError || rethrow()
removed = ex
end
removed = tryrmopenfile(path)
end
close(lock.fd)
havelock = removed === true
Expand Down

0 comments on commit c874cdb

Please sign in to comment.