Skip to content

Commit

Permalink
Fix: Fix copytruncate to work when another process has an read lock…
Browse files Browse the repository at this point in the history
… on the log file

Fixes #52
  • Loading branch information
leojonathanoh committed Mar 4, 2024
1 parent 6bb4ef4 commit 9a42543
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 9a42543

Please sign in to comment.