potatoqualitee / kbupdate

🛡 KB Viewer, Saver, Installer and Uninstaller
MIT License
326 stars 48 forks source link

Possible issue in Save-KbUpdate with array of URLs instead of scalar string #218

Open codaamok opened 1 year ago

codaamok commented 1 year ago

Hey, I have a question regarding this line:

https://github.com/potatoqualitee/kbupdate/blob/main/public/Save-KbUpdate.ps1#L260

Do you think it should be $hyperlinklol = $dl.Link instead of what it is now? I haven't actually seen this happen, but from reading the code, if $hyperlinklol were an array, then Start-BitsTransfer could download from multiple URLs but to the same -Destination $file.

Start-BitsTransfer accepts an array for -Source so it's likely this could happen, whereas Invoke-WebRequest only accepts scalar string for -Uri.

I would change it but I guess the question is, have you ever seen a single update have multiple download URLs? If no, then we could probably change it. If you have, then we may want to rethink how it downloads.

As an aside, I have a PR incoming to solve a bug in this function where if Start-BitsTransfer throws an error - and then retries with Invoke-TlsWebrequest - then an output FileInfo (from Get-ChildItem) is not returned. It downloads fine, there just isn't any handling to then return an output. This causes an error to bubble up to here (as $updateFile is null) about -Path being null:

https://github.com/potatoqualitee/kbupdate/blob/main/private/Start-DscUpdate.ps1#L288