majkinetor / au

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

Chocolatey expected a file at (...) to be of length '143766843' but the length was '143865528'. #182

Closed chtof closed 5 years ago

chtof commented 5 years ago

Hi,

I have this issue:

.\update.ps1
gravitdesigner.install - checking updates using au version 2018.5.18

URL check
nuspec version: 3.5.14
remote version: 2019.1.6
New version is available
Automatic checksum started
Downloading chocolatey\gravitdesigner.install 32 bit
  from 'https://designer.gravit.io/_downloads/windows/GravitDesignerInstaller.exe'

Download of GravitDesignerInstaller.exe (-1 B) completed.
Chocolatey expected a file at 'C:\...\chocolatey\gravitdesigner.install\2019.1.6\chocolatey\GravitDesignerInstaller.exe' to be of length '143766843' but the length was '143865528'.
Au caractère C:\...\chocolatey\au\chocolatey\helpers\functions\Get-ChocolateyWebFile.ps1:373 : 101
+ ... ngth"]))  { throw "Chocolatey expected a file at '$fileFullPath' to b ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Chocolatey expe...as '143865528'.:String) [], RuntimeException
    + FullyQualifiedErrorId : Chocolatey expected a file at 'C:\...\chocolatey\gravitdesigner.install\2019.1.6\chocolatey\GravitDesignerInstaller.exe' to be of length '143766843' but the length was '143865528'.

How can I handle this issue? Thanks in advance for your help.

AdmiringWorm commented 5 years ago

This is a known problem in chocolatey (which au uses for automatic checksums).

You need to disable automatic checksums and generate those checksums yourself (partly).

add the following funciton to the au update.ps1 file (make any necessary changes that you want).

function global:au_BeforeUpdate {
    $Latest.ChecksumType32 = 'sha256' # Not necessary, but just my preference to add it
    $Latest.Checksum32 = Get-RemoteChecksum $Latest.URL32 -Algorithm $Latest.ChecksumTyp32 # You can omit the algorithm, the function will use sha256 by default
}

then you need to change your call to update at the end of the file, change it to update -ChecksumFor none

EDIT: Here is the issue for chocolatey https://github.com/chocolatey/choco/issues/1422

majkinetor commented 5 years ago

Besides that, if you embed files you don't even need this as Get-RemoteFiles will calculate checksums. THat is what you should prefer nowdays, I almost never use automatic checksum because almost all packages I create are embedded.

chtof commented 5 years ago

[SOLVED] Thanks a lot for your help!