Skip Menu |

This queue is for tickets about the App-perlbrew CPAN distribution.

Report information
The Basics
Id: 113087
Status: resolved
Priority: 0/
Queue: App-perlbrew

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.74
Fixed in: (no value)



Subject: SIGINT interruption leaves partially downloaded files
If you hit Ctrl-C to interrupt a `perlbrew install`, perhaps because you realise you forgot a commandline option, if perlbrew has started to download the distribution tarball but it hasn't completed yet, it will leave behind that partial file. $ perlbrew install perl-5.23.8 Fetching perl 5.23.8 as /home/leo/perl5/perlbrew/dists/perl-5.23.8.tar.bz2 Download http://www.cpan.org/src/5.0/perl-5.23.8.tar.bz2 to /home/leo/perl5/perlbrew/dists/perl-5.23.8.tar.bz2 ^CERROR: Failed to download http://www.cpan.org/src/5.0/perl-5.23.8.tar.bz2 $ ll perl5/perlbrew/dists/ total 316M ... -rw-r--r-- 1 leo leo 296K Mar 16 14:46 perl-5.23.8.tar.bz2 Trying to resume this with different options then complains: $ perlbrew install perl-5.23.8 bzip2: Compressed file ends unexpectedly; perhaps it is corrupted? *Possible* reason follows. ... It would be nice to put a local $SIG{INT} = local $SIG{TERM} = sub { unlink (the download file); }; in the code here to avoid this upset. -- Paul Evans
On 2016-03-16 10:51:59, PEVANS wrote: Show quoted text
> If you hit Ctrl-C to interrupt a `perlbrew install`, perhaps because > you realise you forgot a commandline option, if perlbrew has started > to download the distribution tarball but it hasn't completed yet, it > will leave behind that partial file. > > $ perlbrew install perl-5.23.8 > Fetching perl 5.23.8 as /home/leo/perl5/perlbrew/dists/perl- > 5.23.8.tar.bz2 > Download http://www.cpan.org/src/5.0/perl-5.23.8.tar.bz2 to > /home/leo/perl5/perlbrew/dists/perl-5.23.8.tar.bz2 > ^CERROR: Failed to download http://www.cpan.org/src/5.0/perl- > 5.23.8.tar.bz2 > > $ ll perl5/perlbrew/dists/ > total 316M > ... > -rw-r--r-- 1 leo leo 296K Mar 16 14:46 perl-5.23.8.tar.bz2 > > Trying to resume this with different options then complains: > > $ perlbrew install perl-5.23.8 > > bzip2: Compressed file ends unexpectedly; > perhaps it is corrupted? *Possible* reason follows. > ... > > It would be nice to put a > > local $SIG{INT} = local $SIG{TERM} = sub { > unlink (the download file); > }; > > in the code here to avoid this upset.
It would be more robust to download to a temporary file and do an atomic rename only if it was successful. The sig handlers can still be there to unlink the temporary file.
I just pushed a commit to handle this case https://github.com/gugod/App-perlbrew/commit/f667bde37c531f40edcfe7476a698c50f1e6139b feel free to iterate further.