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:
Jordan Borean 2017-08-07 12:04:42 +10:00 committed by GitHub
commit 107e177658
2 changed files with 32 additions and 2 deletions

View file

@ -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)"
}
}
}
}