Skip to content
Snippets Groups Projects
Commit c2445423 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard: Committed by Niko Ehrenfeuchter (adm)
Browse files

Minor logging changes.

Refers to #13
parent 01ac3f7a
No related branches found
No related tags found
No related merge requests found
......@@ -90,7 +90,7 @@ function Update-FileIfNewer([string]$SourcePath, [string]$Destination) {
$SrcFileSuffix = [io.path]::GetExtension($SrcFile)
$DstPath = "$($Destination)\$($SrcFile)"
if (-Not (Test-Path "$DstPath")) {
Write-Host "File not existing in destination, NOT UPDATING: $DstPath"
Log-Info "File not existing in destination, NOT UPDATING: $($DstPath)"
Return
}
......@@ -104,14 +104,15 @@ function Update-FileIfNewer([string]$SourcePath, [string]$Destination) {
$BakTimeStamp = Get-Date -Format s | foreach {$_ -replace ":", "."}
$BakName = "$($SrcFileNoSuffix)_pre-$BakTimeStamp$SrcFileSuffix"
Write-Host "Creating backup: $($BakName)"
Rename-Item "$DstPath" "$Destination\$BakName"
Log-Info "Creating backup of '$($DstPath)' to '$($BakName)'."
try {
Copy-Item -Path $SourcePath -Destination $Destination -ErrorAction Stop
Log-Info "Updated config file '$($DstPath)'."
}
catch {
$ex = $_.Exception.Message
Log-Error -Message "Copying $($SourcePath) FAILED!`n$($ex)"
Log-Error "Copying $($SourcePath) FAILED!`n$($ex)"
Exit
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment