You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/net-misc/snarf/files/snarf-unlink-empty.diff

38 lines
1.5 KiB

diff -urN snarf-7.0.orig/http.c snarf-7.0/http.c
--- snarf-7.0.orig/http.c 2003-08-01 14:46:26.000000000 +0100
+++ snarf-7.0/http.c 2003-08-01 14:44:02.000000000 +0100
@@ -447,6 +447,10 @@
cleanup:
free_http_header(header);
close(sock); fclose(out);
+ if ((rsrc->open_created) && (rsrc->outfile_size == 0)
+ && (retval == 0))
+ if (unlink(rsrc->outfile))
+ report(ERR, "unlink %s: %s", rsrc->outfile, strerror(errno));
return retval;
}
diff -urN snarf-7.0.orig/url.h snarf-7.0/url.h
--- snarf-7.0.orig/url.h 2003-08-01 14:46:26.000000000 +0100
+++ snarf-7.0/url.h 2003-08-01 13:27:22.000000000 +0100
@@ -25,6 +25,7 @@
struct _UrlResource {
Url *url;
char *outfile;
+ unsigned int open_created;
char *proxy;
char *proxy_username;
char *proxy_password;
diff -urN snarf-7.0.orig/util.h snarf-7.0/util.h
--- snarf-7.0.orig/util.h 2000-08-09 01:12:25.000000000 +0100
+++ snarf-7.0/util.h 2003-08-01 14:53:54.000000000 +0100
@@ -53,7 +53,7 @@
extern int debug_enabled;
#define open_outfile(x) (((x)->outfile[0] == '-') ? stdout : real_open_outfile(x))
-#define real_open_outfile(x) (((x)->options & OPT_RESUME && !((x)->options & OPT_NORESUME)) ? (fopen((x)->outfile, "a")) : (fopen((x)->outfile, "w")))
+#define real_open_outfile(x) (((x)->open_created = (access ((x)->outfile, F_OK)) ? 1 : 0 ),((x)->options & OPT_RESUME && !((x)->options & OPT_NORESUME)) ? (fopen((x)->outfile, "a")) : (fopen((x)->outfile, "w")))
#define safe_free(x) if(x) free(x)
#define safe_strdup(x) ( (x) ? strdup(x) : NULL )