>Number: 144919 >Category: bin >Synopsis: [patch] [pkg_install] Remove partially downloaded file on >fetch failure >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Mar 21 01:30:01 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Garrett Cooper >Release: 9-CURRENT >Organization: Cisco Systems, Inc. >Environment: FreeBSD bayonetta.local 9.0-CURRENT FreeBSD 9.0-CURRENT #5 r205310: Sat Mar 20 01:32:51 PDT 2010 gcoo...@bayonetta.local:/usr/obj/usr/src/sys/BAYONETTA amd64 >Description: An annoyance I've had to deal with over the past week is that pkg_add -Kr on DNS resolution failure retains dummy 0 byte packages instead of deleting them on fetch failure.
This patch removes the file when the fetch fails. >How-To-Repeat: pkg_add -Kr a_package_that_does_not_exist.tbz >Fix: See patch. Patch attached with submission follows: ==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/lib/url.c#1 - /scratch/freebsd/perforce/pkg_install-enhancements/usr.sbin/pkg_install/lib/url.c ==== @@ -108,6 +108,10 @@ if ((ftp = fetchGetURL(fname, Verbose ? "v" : NULL)) == NULL) { printf("Error: Unable to get %s: %s\n", fname, fetchLastErrString); + /* If the fetch fails, yank the package. */ + if (keep_package && unlink(pkg) < 0 && Verbose) { + warnx("failed to remove partially fetched package: %s", pkg); + } return NULL; } >Release-Note: >Audit-Trail: >Unformatted: _______________________________________________ freebsd-bugs@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"