Frugalware

Please read the http://frugalware.org/docs/bugs page if you are new to bugreporting!
Tasklist

FS#2598 - libpacman support for cancelling downloading of packages

Attached to Project: Frugalware
Opened by Priyank (priyank) - Saturday, 24 November 2007, 20:49 GMT+2
Last edited by Priyank (priyank) - Saturday, 24 November 2007, 20:50 GMT+2
Task Type Feature Request
Category Applications
Status Assigned
Assigned To Miklos Vajna (vmiklos)
Operating System i686
Severity Medium
Priority Normal
Reported Version -current
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

It would be good to have some kind of functionality in the libpacman library to cancel fetching of a package. This is very useful (and needed) for a frontend like Gfpm where the user might want to cancel the process of fetching the packages from the servers.
This task depends upon

Comment by Miklos Vajna (vmiklos) - Sunday, 09 December 2007, 03:15 GMT+2
could you please try if just using pacman_trans_release() is enough?
Comment by Priyank (priyank) - Sunday, 02 March 2008, 14:08 GMT+2
nope, pacman_trans_release() doesn't work. The downloading still goes on.
Comment by Priyank (priyank) - Sunday, 06 April 2008, 07:54 GMT+2
I tried using pacman_release() but, it doesn't seem to execute that function unless and until the _current_ ongoing package fetch is over. Once that fetch is over, it seems to have run pacman_release() and endup with a segfault.
Comment by Priyank (priyank) - Sunday, 06 April 2008, 08:15 GMT+2
Also, i just checked the source of pacman_release() and i found that there was no call made to FtpQuit() in this function, which means the downloading would never stop.
Comment by Miklos Vajna (vmiklos) - Monday, 07 April 2008, 16:00 GMT+2
that makes sense. i'll try to have a look at it soon.
Comment by Miklos Vajna (vmiklos) - Wednesday, 09 April 2008, 01:50 GMT+2
ok, i see the problem now. in pacman, we just don't overwrite SIGINT during the download, that's why there is no problem. there is a trivial fix: set the transaction's state the interrupted if the state is downloading as well. the question is how to interrupt FtpGet: at the moment what would be trivial is to wait for the end of the current file :S
Comment by Miklos Vajna (vmiklos) - Wednesday, 09 April 2008, 02:45 GMT+2
i think finally i solved this.

here is how it is possible to interrupt a download.

first call pacman_trans_release(), that'll give you a PM_ERR_TRANS_DOWNLOADING error. that means the following:

1) a download was in progress

2) you should return 0 (it means an error there) in the download callback next time.

then pacman_trans_commit() will return with a PM_ERR_RETRIEVE error, and you can call pacman_trans_release() which will return no error.

if something is not obvious, here are the two relevant commits from pacman-g2.git:

libpacman change (not too interesting):

http://frugalware.org/pipermail/frugalware-git/2008-April/010388.html

pacman-g2 change (you should do something like this):

http://frugalware.org/pipermail/frugalware-git/2008-April/010387.html

feel free to close this bug once it works in gfpm as well :)
Comment by Priyank (priyank) - Wednesday, 09 April 2008, 12:09 GMT+2
nope, the downloading doesn't stop even after the progress callback returns 0 (the callback is still active)
Because of this, pacman_trans_commit() never returns, and eventually, it doesn't work.
Comment by Priyank (priyank) - Thursday, 17 April 2008, 21:23 GMT+2
vmiklos: any updates on this ?
Comment by Miklos Vajna (vmiklos) - Friday, 18 April 2008, 14:50 GMT+2
hm, interesting. this is what i have with pacman-g2.git:

$ sudo ./pacman-g2 -Sccw kernel-source
Do you want to remove all packages from cache? [Y/n]

removing all packages from cache... done.
resolving dependencies... done.

Targets: kernel-source-2.6.24-5

Total Package Size: 43.3 MB

Total Uncompressed Package Size: 243.1 MB

Proceed with download? [Y/n]


:: Retrieving packages from frugalware-current...
(1/1) kernel-source-2.6. [######## ] 54% 24112K 0.0K/s 00:00:00

[14:46:42] warning: failed to retrieve some files from frugalware-current

error: failed to commit transaction (coult not retrieve the file)

errors occurred, no packages were upgraded.

so pacman_trans_commit() returns PM_ERR_RETRIEVE after i return 0 in the callback.

how does this work in gfpm? do you have a callback function when the user presses the "cancel" button and then you set some variable to let the download callback know about it should return 0?

thanks

Loading...