windows - Fix module utils with glob paths (#53835)

* windows - Fix module utils with glob paths

* fix link util tests when using DOS 8.3 paths
This commit is contained in:
Jordan Borean 2019-03-15 19:44:53 +10:00 committed by GitHub
commit 980ca564ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 26 deletions

View file

@ -321,7 +321,7 @@ Function Get-FileChecksum($path, $algorithm = 'sha1')
Helper function to calculate a hash of a file in a way which PowerShell 3
and above can handle
#>
If (Test-Path -Path $path -PathType Leaf)
If (Test-Path -LiteralPath $path -PathType Leaf)
{
switch ($algorithm)
{
@ -334,7 +334,7 @@ Function Get-FileChecksum($path, $algorithm = 'sha1')
}
If ($PSVersionTable.PSVersion.Major -ge 4) {
$raw_hash = Get-FileHash $path -Algorithm $algorithm
$raw_hash = Get-FileHash -LiteralPath $path -Algorithm $algorithm
$hash = $raw_hash.Hash.ToLower()
} Else {
$fp = [System.IO.File]::Open($path, [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::ReadWrite);
@ -342,7 +342,7 @@ Function Get-FileChecksum($path, $algorithm = 'sha1')
$fp.Dispose();
}
}
ElseIf (Test-Path -Path $path -PathType Container)
ElseIf (Test-Path -LiteralPath $path -PathType Container)
{
$hash = "3";
}