pkgng/pkgng — pull request #398 by namore (2012-11-27 22:45:32+00:00)
Title: fixes issue #377

See https://github.com/pkgng/pkgng/pull/397 , conforms to style(9) this time. (changed comment syntax from // to /* ... */. Thanks @bapt for feedback.

PS.: We didn't add the 'unlink' call as discussed with @bapt on IRC for the following reason:
- This is merely a "display format" function. It should shows the estimated download size - not change the filesystem.
- "pkg install screen" asks for confirmation. If you say "No" pkg should not change the filesystem in our opinion. Adding the 'unlink' call to the display function would delete (invalid) cached package files even if you say "No" at the confirmation dialog.

We suggest to add a size-check before the checksum check to pkg_repo_fetch() in libpkg/pkg_repo.c near line 218 - if you do not want to make unneeded checksum checks when the file size is off anyways. Another advantage of this is that it becomes easier to add a "continue downloads" feature later (since incomplete files wont get deleted earlier in the "display format" function).