mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
win_stat: add explicit error message when file is in use (#27826)
* win_stat: add explicit error message when file is in use * make the lock last a bit longer
This commit is contained in:
parent
3ceeb5124e
commit
107e177658
2 changed files with 32 additions and 2 deletions
|
@ -168,11 +168,19 @@ If (Test-Path -Path $path)
|
|||
$result.stat.size = $info.Length
|
||||
|
||||
If ($get_md5) {
|
||||
$result.stat.md5 = Get-FileChecksum -path $path -algorithm "md5"
|
||||
try {
|
||||
$result.stat.md5 = Get-FileChecksum -path $path -algorithm "md5"
|
||||
} catch {
|
||||
Fail-Json -obj $result -message "failed to get MD5 hash of file, set get_md5 to False to ignore this error: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
If ($get_checksum) {
|
||||
$result.stat.checksum = Get-FileChecksum -path $path -algorithm $checksum_algorithm
|
||||
try {
|
||||
$result.stat.checksum = Get-FileChecksum -path $path -algorithm $checksum_algorithm
|
||||
} catch {
|
||||
Fail-Json -obj $result -message "failed to get hash of file, set get_checksum to False to ignore this error: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue