Date: Sun, 21 Mar 2010 01:25:36 GMT From: Garrett Cooper <gcooper@FreeBSD.org> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/144919: [patch] [pkg_install] Remove partially downloaded file on fetch failure Message-ID: <201003210125.o2L1Pah4063856@www.freebsd.org> Resent-Message-ID: <201003210130.o2L1U1tO002668@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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 gcooper@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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201003210125.o2L1Pah4063856>
