Fix up sanity problems

pull/79280/head
Jordan Borean 2 years ago
parent 4ad02dc6e3
commit 6def4a3180

@ -135,11 +135,11 @@ try {
# populate initial results before we send the async data to avoid result race # populate initial results before we send the async data to avoid result race
$result = @{ $result = @{
started = 1; started = 1
finished = 0; finished = 0
results_file = $results_path; results_file = $results_path
ansible_job_id = $local_jid; ansible_job_id = $local_jid
_ansible_suppress_tmpdir_delete = $true; _ansible_suppress_tmpdir_delete = $true
ansible_async_watchdog_pid = $watchdog_pid ansible_async_watchdog_pid = $watchdog_pid
} }

@ -18,7 +18,7 @@ Function Backup-File {
Process { Process {
$backup_path = $null $backup_path = $null
if (Test-Path -LiteralPath $path -PathType Leaf) { if (Test-Path -LiteralPath $path -PathType Leaf) {
$backup_path = "$path.$pid." + [DateTime]::Now.ToString("yyyyMMdd-HHmmss") + ".bak"; $backup_path = "$path.$pid." + [DateTime]::Now.ToString("yyyyMMdd-HHmmss") + ".bak"
Try { Try {
Copy-Item -LiteralPath $path -Destination $backup_path Copy-Item -LiteralPath $path -Destination $backup_path
} }

@ -354,16 +354,16 @@ Function Get-FileChecksum($path, $algorithm = 'sha1') {
$hash = $raw_hash.Hash.ToLower() $hash = $raw_hash.Hash.ToLower()
} }
Else { Else {
$fp = [System.IO.File]::Open($path, [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::ReadWrite); $fp = [System.IO.File]::Open($path, [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::ReadWrite)
$hash = [System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace("-", "").ToLower(); $hash = [System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace("-", "").ToLower()
$fp.Dispose(); $fp.Dispose()
} }
} }
ElseIf (Test-Path -LiteralPath $path -PathType Container) { ElseIf (Test-Path -LiteralPath $path -PathType Container) {
$hash = "3"; $hash = "3"
} }
Else { Else {
$hash = "1"; $hash = "1"
} }
return $hash return $hash
} }

@ -2,5 +2,5 @@
# passed to the script. # passed to the script.
foreach ($i in $args) { foreach ($i in $args) {
Write-Host $i; Write-Host $i
} }

@ -2,7 +2,7 @@
trap { trap {
Write-Error -ErrorRecord $_ Write-Error -ErrorRecord $_
exit 1; exit 1
} }
throw "Oh noes I has an error" throw "Oh noes I has an error"

@ -16,16 +16,16 @@
# POWERSHELL_COMMON # POWERSHELL_COMMON
$params = Parse-Args $args $true; $params = Parse-Args $args $true
$data = Get-Attr $params "data" "pong"; $data = Get-Attr $params "data" "pong"
$result = @{ $result = @{
changed = $false changed = $false
ping = "pong" ping = "pong"
}; }
# Test that Set-Attr will replace an existing attribute. # Test that Set-Attr will replace an existing attribute.
Set-Attr $result "ping" $data Set-Attr $result "ping" $data
Exit-Json $result; Exit-Json $result

@ -16,15 +16,15 @@
# POWERSHELL_COMMON # POWERSHELL_COMMON
$params = Parse-Args $args $true; $params = Parse-Args $args $true
$params.thisPropertyDoesNotExist $params.thisPropertyDoesNotExist
$data = Get-Attr $params "data" "pong"; $data = Get-Attr $params "data" "pong"
$result = @{ $result = @{
changed = $false changed = $false
ping = $data ping = $data
}; }
Exit-Json $result; Exit-Json $result

@ -18,13 +18,13 @@
$blah = 'I can't quote my strings correctly.' $blah = 'I can't quote my strings correctly.'
$params = Parse-Args $args $true; $params = Parse-Args $args $true
$data = Get-Attr $params "data" "pong"; $data = Get-Attr $params "data" "pong"
$result = @{ $result = @{
changed = $false changed = $false
ping = $data ping = $data
}; }
Exit-Json $result; Exit-Json $result

@ -18,13 +18,13 @@
throw throw
$params = Parse-Args $args $true; $params = Parse-Args $args $true
$data = Get-Attr $params "data" "pong"; $data = Get-Attr $params "data" "pong"
$result = @{ $result = @{
changed = $false changed = $false
ping = $data ping = $data
}; }
Exit-Json $result; Exit-Json $result

@ -18,13 +18,13 @@
throw "no ping for you" throw "no ping for you"
$params = Parse-Args $args $true; $params = Parse-Args $args $true
$data = Get-Attr $params "data" "pong"; $data = Get-Attr $params "data" "pong"
$result = @{ $result = @{
changed = $false changed = $false
ping = $data ping = $data
}; }
Exit-Json $result; Exit-Json $result

Loading…
Cancel
Save