Refactor function for waiting for download
This commit is contained in:
parent
164430e9b4
commit
7db3d35e86
1 changed files with 16 additions and 10 deletions
|
@ -28,19 +28,25 @@ function Start-AutomatedDownload() {
|
||||||
$downloadChecker = {
|
$downloadChecker = {
|
||||||
param()
|
param()
|
||||||
|
|
||||||
foreach ($file in Get-ChildItem $tempDir) {
|
$files = Get-ChildItem $tempDir;
|
||||||
try {
|
|
||||||
$stream = [System.IO.File]::Open($file.FullName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None);
|
|
||||||
|
|
||||||
if ($stream) {
|
if ($(@($files)).Count -ge 0) {
|
||||||
$stream.Close();
|
foreach ($file in Get-ChildItem $tempDir) {
|
||||||
|
try {
|
||||||
|
$stream = [System.IO.File]::Open($file.FullName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None);
|
||||||
|
|
||||||
|
if ($stream) {
|
||||||
|
$stream.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $false;
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return $true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $false;
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
return $true;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return $false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue