File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -458,9 +458,7 @@ function Setup-Collector {
458458
459459 $configContent = ($configLines -join [Environment ]::NewLine) + [Environment ]::NewLine
460460 $utf8NoBom = New-Object System.Text.UTF8Encoding $false
461- $configUpdateId = [guid ]::NewGuid().ToString(' N' )
462- $tempConfigFile = " $CONFIG_FILE .$configUpdateId .tmp"
463- $backupConfigFile = " $CONFIG_FILE .$configUpdateId .bak"
461+ $tempConfigFile = " $CONFIG_FILE .$ ( [guid ]::NewGuid().ToString(' N' )) .tmp"
464462
465463 try {
466464 $tempConfigStream = [System.IO.File ]::Create($tempConfigFile )
@@ -488,22 +486,14 @@ function Setup-Collector {
488486 exit 1
489487 }
490488
491- if (Test-Path $CONFIG_FILE ) {
492- Set-Acl - Path $CONFIG_FILE - AclObject $acl - ErrorAction Stop
493- [System.IO.File ]::Replace($tempConfigFile , $CONFIG_FILE , $backupConfigFile )
494- }
495- else {
496- [System.IO.File ]::Move($tempConfigFile , $CONFIG_FILE )
497- }
498- Set-Acl - Path $CONFIG_FILE - AclObject $acl - ErrorAction Stop
489+ Move-Item - LiteralPath $tempConfigFile - Destination $CONFIG_FILE - Force - ErrorAction Stop
499490 }
500491 catch {
501492 Write-ErrorMsg " Failed to update OpenTelemetry Collector configuration: $_ "
502493 exit 1
503494 }
504495 finally {
505496 Remove-Item $tempConfigFile - Force - ErrorAction SilentlyContinue
506- Remove-Item $backupConfigFile - Force - ErrorAction SilentlyContinue
507497 }
508498
509499 if (Test-CollectorRunning ) {
You can’t perform that action at this time.
0 commit comments