mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
Switched to SHA1 checksum instead of MD5
This commit is contained in:
parent
1a8b9b8935
commit
44cc1a75ba
2 changed files with 8 additions and 10 deletions
|
@ -52,17 +52,17 @@ if (Test-Path $dest -PathType Container)
|
||||||
|
|
||||||
If (Test-Path $dest)
|
If (Test-Path $dest)
|
||||||
{
|
{
|
||||||
$dest_md5 = Get-FileMd5 ($dest);
|
$dest_checksum = Get-FileChecksum ($dest);
|
||||||
$src_md5 = Get-FileMd5 ($src);
|
$src_checksum = Get-FileChecksum ($src);
|
||||||
|
|
||||||
If (! $src_md5.CompareTo($dest_md5))
|
If (! $src_checksum.CompareTo($dest_checksum))
|
||||||
{
|
{
|
||||||
# New-Item -Force creates subdirs for recursive copies
|
# New-Item -Force creates subdirs for recursive copies
|
||||||
New-Item -Force $dest -Type file;
|
New-Item -Force $dest -Type file;
|
||||||
Copy-Item -Path $src -Destination $dest -Force;
|
Copy-Item -Path $src -Destination $dest -Force;
|
||||||
}
|
}
|
||||||
$dest_md5 = Get-FileMd5 ($dest);
|
$dest_checksum = Get-FileChecksum ($dest);
|
||||||
If ( $src_md5.CompareTo($dest_md5))
|
If ( $src_checksum.CompareTo($dest_checksum))
|
||||||
{
|
{
|
||||||
$result.changed = $TRUE;
|
$result.changed = $TRUE;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ Else
|
||||||
$result.changed = $TRUE;
|
$result.changed = $TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dest_checksum = Get-FileMd5($dest);
|
$dest_checksum = Get-FileChecksum($dest);
|
||||||
$result.checksum = $dest_checksum;
|
$result.checksum = $dest_checksum;
|
||||||
|
|
||||||
Exit-Json $result;
|
Exit-Json $result;
|
||||||
|
|
|
@ -53,11 +53,9 @@ Else
|
||||||
|
|
||||||
If ($get_md5 -and $result.stat.exists -and -not $result.stat.isdir)
|
If ($get_md5 -and $result.stat.exists -and -not $result.stat.isdir)
|
||||||
{
|
{
|
||||||
$sp = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider;
|
$hash = Get-FileChecksum($path);
|
||||||
$fp = [System.IO.File]::Open($path, [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read);
|
|
||||||
$hash = [System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace("-", "").ToLower();
|
|
||||||
$fp.Dispose();
|
|
||||||
Set-Attr $result.stat "md5" $hash;
|
Set-Attr $result.stat "md5" $hash;
|
||||||
|
Set-Attr $result.stat "checksum" $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
Exit-Json $result;
|
Exit-Json $result;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue