FS#18769 - compute package download size outside _alpm_sync_prepare

Attached to Project: Pacman
Opened by Jonathan Conder (PirateJonno) - Sunday, 21 March 2010, 00:54 GMT
Last edited by Allan McRae (Allan) - Sunday, 16 May 2010, 04:57 GMT
Task Type Feature Request
Category Backend/Core
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version 3.3.3
Due in Version 3.4.0
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Currently alpm_package_download_size returns 0 unless a sync transaction has already been prepared. This of course works fine for pacman itself, but for the frontend I am writing, I need to be able to display the download size before a transaction has been prepared (or even created). Would it be possible to allow for this in the alpm_package_download_size function? My idea would be to add another infolevel and only compute the download size when the value is not already known. I would be happy to write a patch for this if you agree.
This task depends upon

Closed by  Allan McRae (Allan)
Sunday, 16 May 2010, 04:57 GMT
Reason for closing:  Implemented
Additional comments about closing:  git commit df99495
Comment by Xavier (shining) - Sunday, 21 March 2010, 01:17 GMT
#pacman-dev IRC yesterday :

01:17 < shining^> DigitalKiwi: download size is computed at sync_prepare stage
01:18 < DigitalKiwi> hrm
01:18 < shining^> I suppose thats not what you wanted
01:19 < DigitalKiwi> in trans_prepare is that?
01:20 < shining^> yup
01:21 < DigitalKiwi> hurr shit that's annoying :(
01:21 < shining^> patch welcome :D
01:22 < shining^> Nagy mentioned that problem to me at least 2 or 3 times in last year
01:23 < DigitalKiwi> well at least now I know what is wrong
01:23 < DigitalKiwi> thanks
01:25 < shining^>pacman-dev@archlinux.org/msg01319.html"> http://www.mail-archive.com/pacman-dev@archlinux.org/msg01319.html
01:25 < phrik> Title: Re: [pacman-dev] Move -Sw to front-end (at www.mail-archive.com)
Comment by Jonathan Conder (PirateJonno) - Sunday, 21 March 2010, 02:57 GMT
ok, thanks for the info. At the moment I'm looking at invalidating the download sizes of all the trans->packages just after _alpm_download_files is called in sync.c. As far as I can tell the only other place where packages are downloaded to the cache is in alpm_fetch_pkgurl, which I think is so rarely used we don't need to worry about updating download sizes. Should have a patch ready in a few days, depending on my schedule.
Comment by Dan McGee (toofishes) - Tuesday, 23 March 2010, 03:43 GMT
It looks like if the logic in compute_download_size() is just turned into an accessor method on the package "object" this will work. We could have a sentinel value of -1 here on that field by default, and then actually execute all the logic if that is still set to -1. As you noted, there would need to be certain times when these values are invalidated as well.

alpm_fetch_pkgurl is used for a "pacman -U http://my.packages.com/pkg.tar.gz&quot; type operation.

Patches welcome as usual on the ML. :)
Comment by Jonathan Conder (PirateJonno) - Thursday, 25 March 2010, 04:55 GMT
Ok, here's my email: http://mailman.archlinux.org/pipermail/pacman-dev/2010-March/010556.html
Somehow the MIME types got messed up (I think) so I've uploaded the patch here too:
http://omploader.org/vM3h2aQ/pm.patch

Loading...