summaryrefslogtreecommitdiff
path: root/net-misc/snarf/files/snarf-unlink-empty.diff
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /net-misc/snarf/files/snarf-unlink-empty.diff
reinit the tree, so we can have metadata
Diffstat (limited to 'net-misc/snarf/files/snarf-unlink-empty.diff')
-rw-r--r--net-misc/snarf/files/snarf-unlink-empty.diff37
1 files changed, 37 insertions, 0 deletions
diff --git a/net-misc/snarf/files/snarf-unlink-empty.diff b/net-misc/snarf/files/snarf-unlink-empty.diff
new file mode 100644
index 000000000000..66f3089b0b63
--- /dev/null
+++ b/net-misc/snarf/files/snarf-unlink-empty.diff
@@ -0,0 +1,37 @@
+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 )