majkinetor / au

Chocolatey Automatic Package Updater Module
GNU General Public License v2.0
227 stars 71 forks source link

Updating $Latest parameter after au_GetLatest function call #262

Closed alwaysharsha closed 2 years ago

alwaysharsha commented 2 years ago

We have a scenario where we download the vs_professional.exe (Visual Studio Professional) To detect the version. We create offline iso so that our installation is consistent. Downloading Visual studio components and iso takes lot of them around 20-30 mins. If there is no version change I can save that time without creating the iso file.

The current flow is au_GetLatest (Download .exe and creates .iso and returns the object including checksum and file path) -> au_SearchReplace -> au_AfterUpdate.

Instead of creating the iso at au_GetLatest if I move to a later stage like au_SearchReplace I would save time when there is no new version. During this step is it recommended to update the $global:Latest parameter with new values and reference them? Is that acceptable solution.

Please let me know your views.

majkinetor commented 2 years ago

You should create iso within au_BeforeUpdate which is exactly there for such scenarios. In that step it is typical to change $Latest, for example people often call here Get-RemoteFiles which internally sets the checksums on it.

Your current solution will probably work but it is a mess and mixes concerns - GetLatest job is only to find latest version and url, not construct thing needed for eventual update. Adding things to SearchReplace might work or not, but it definitely smells bad.

rismoney commented 2 years ago

here is how i used to do it: https://github.com/rismoney/chocolatey-package-recipes/blob/master/vs2017-professional/vs2017-professional/update.ps1

alwaysharsha commented 2 years ago

Thanks @rismoney