Skip to content

Commit

Permalink
Merge pull request #67 from leojonathanoh/fix/fix-copytruncate-to-wor…
Browse files Browse the repository at this point in the history
…k-when-another-process-has-an-read-lock-on-the-log-file

Fix: Fix `copytruncate` to work when another process has an read lock on the log file
  • Loading branch information
leojonathanoh authored Mar 4, 2024
2 parents 6bb4ef4 + 9a42543 commit e5a9167
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Log-Rotate/classes/New-LogObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ function New-LogObject {
if ($copytruncate) {
Write-Verbose "Truncating $my_fullname"
if (!$WhatIf) {
Clear-Content $my_fullname
# Truncate the file
[IO.File]::WriteAllText($my_fullname, '')
}
}else {
Write-Verbose "Not truncating $my_fullname"
Expand Down

0 comments on commit e5a9167

Please sign in to comment.