Skip to content
Snippets Groups Projects
Commit 0565dfbf authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Output formatting consistency.

All file and directory names are to be enclosed into square brackets.
parent ea16a410
No related branches found
No related tags found
No related merge requests found
...@@ -135,7 +135,7 @@ function Get-WriteTime([string]$FileName) { ...@@ -135,7 +135,7 @@ function Get-WriteTime([string]$FileName) {
} }
catch { catch {
$ex = $_.Exception.Message $ex = $_.Exception.Message
Log-Error "Error determining file age of '$($FileName)'!`n$($ex)" Log-Error "Error determining file age of [$($FileName)]!`n$($ex)"
Exit Exit
} }
Return $TimeStamp Return $TimeStamp
...@@ -144,7 +144,7 @@ function Get-WriteTime([string]$FileName) { ...@@ -144,7 +144,7 @@ function Get-WriteTime([string]$FileName) {
function File-IsUpToDate([string]$ExistingFile, [string]$UpdateCandidate) { function File-IsUpToDate([string]$ExistingFile, [string]$UpdateCandidate) {
# Compare write-timestamps, return $False if $UpdateCandidate is newer. # Compare write-timestamps, return $False if $UpdateCandidate is newer.
Write-Verbose "Comparing $($UpdateCandidate) vs. $($ExistingFile)..." Write-Verbose "Comparing [$($UpdateCandidate)] vs. [$($ExistingFile)]..."
$CandidateTime = Get-WriteTime -FileName $UpdateCandidate $CandidateTime = Get-WriteTime -FileName $UpdateCandidate
$ExistingTime = Get-WriteTime -FileName $ExistingFile $ExistingTime = Get-WriteTime -FileName $ExistingFile
if ($CandidateTime -le $ExistingTime) { if ($CandidateTime -le $ExistingTime) {
...@@ -169,13 +169,13 @@ function Create-Backup { ...@@ -169,13 +169,13 @@ function Create-Backup {
# assemble a timestamp string like "2017-12-04T16.41.35" # assemble a timestamp string like "2017-12-04T16.41.35"
$BakTimeStamp = Get-Date -Format s | foreach {$_ -replace ":", "."} $BakTimeStamp = Get-Date -Format s | foreach {$_ -replace ":", "."}
$BakName = "$($FileWithoutSuffix)_pre-$($BakTimeStamp)$($FileSuffix)" $BakName = "$($FileWithoutSuffix)_pre-$($BakTimeStamp)$($FileSuffix)"
Log-Info "Creating backup of '$($FileName)' as '$($BaseDir)\$($BakName)'." Log-Info "Creating backup of [$($FileName)] as [$($BaseDir)\$($BakName)]."
try { try {
Rename-Item "$FileName" "$BaseDir\$BakName" -ErrorAction Stop Rename-Item "$FileName" "$BaseDir\$BakName" -ErrorAction Stop
} }
catch { catch {
$ex = $_.Exception.Message $ex = $_.Exception.Message
Log-Error "Backing up '$($FileName)' as '$($BakName) FAILED!`n$($ex)" Log-Error "Backing up [$($FileName)] as [$($BakName)] FAILED!`n$($ex)"
Exit Exit
} }
} }
...@@ -202,7 +202,7 @@ function Update-File { ...@@ -202,7 +202,7 @@ function Update-File {
$DstFile = "$($DstPath)\$(Split-Path -Leaf $SrcFile)" $DstFile = "$($DstPath)\$(Split-Path -Leaf $SrcFile)"
if (-Not (Test-Path "$DstFile")) { if (-Not (Test-Path "$DstFile")) {
Log-Info "File not existing in destination, NOT UPDATING: $($DstFile)" Log-Info "File not existing in destination, NOT UPDATING: [$($DstFile)]"
Return $False Return $False
} }
...@@ -256,7 +256,7 @@ function Copy-ServiceFiles { ...@@ -256,7 +256,7 @@ function Copy-ServiceFiles {
Write-Host "ERROR: couldn't find package matching '$($Pattern)'!" Write-Host "ERROR: couldn't find package matching '$($Pattern)'!"
Exit Exit
} }
Write-Verbose "Found update source package: $($PkgDir)" Write-Verbose "Found update source package: [$($PkgDir)]"
Stop-MyService "Trying to update service using package [$($PkgDir)]." Stop-MyService "Trying to update service using package [$($PkgDir)]."
Copy-Item -Recurse -Force -ErrorAction Stop ` Copy-Item -Recurse -Force -ErrorAction Stop `
...@@ -267,7 +267,7 @@ function Copy-ServiceFiles { ...@@ -267,7 +267,7 @@ function Copy-ServiceFiles {
Log-Error "Updating service binaries FAILED!`n$($_.Exception.Message)" Log-Error "Updating service binaries FAILED!`n$($_.Exception.Message)"
Exit Exit
} }
Log-Info "Updated service binaries!" Log-Info "Updated service binaries with [$($PkgDir)]."
} }
...@@ -280,13 +280,12 @@ function Update-ServiceBinaries { ...@@ -280,13 +280,12 @@ function Update-ServiceBinaries {
Copy-ServiceFiles Copy-ServiceFiles
try { try {
New-Item -Type File "$MarkerFile" -ErrorAction Stop | Out-Null New-Item -Type File "$MarkerFile" -ErrorAction Stop | Out-Null
Write-Verbose "Created marker file [$($MarkerFile)]." Log-Debug "Created marker file [$($MarkerFile)]."
} }
catch { catch {
Log-Error "Creating [$($MarkerFile)] FAILED!`n$($_.Exception.Message)" Log-Error "Creating [$($MarkerFile)] FAILED!`n$($_.Exception.Message)"
Exit Exit
} }
Log-Info "Service binaries were updated successfully."
Return $True Return $True
} }
......
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