Blame SOURCES/0007-curl-7.63.0-JO-preserve-local-file.patch

b91d92
From ff74657fb645e7175971128a171ef7d5ece40d77 Mon Sep 17 00:00:00 2001
b91d92
From: Daniel Stenberg <daniel@haxx.se>
b91d92
Date: Mon, 17 Dec 2018 12:51:51 +0100
b91d92
Subject: [PATCH] curl -J: do not append to the destination file
b91d92
b91d92
Reported-by: Kamil Dudka
b91d92
Fixes #3380
b91d92
Closes #3381
b91d92
b91d92
Upstream-commit: 4849267197682e69cfa056c2bd7a44acd123a917
b91d92
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
b91d92
---
b91d92
 src/tool_cb_hdr.c  | 6 +++---
b91d92
 src/tool_cb_wrt.c  | 9 ++++-----
b91d92
 src/tool_cb_wrt.h  | 2 +-
b91d92
 src/tool_operate.c | 2 +-
b91d92
 4 files changed, 9 insertions(+), 10 deletions(-)
b91d92
b91d92
diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c
b91d92
index 84b0d9c..3844904 100644
b91d92
--- a/src/tool_cb_hdr.c
b91d92
+++ b/src/tool_cb_hdr.c
b91d92
@@ -148,12 +148,12 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
b91d92
         outs->filename = filename;
b91d92
         outs->alloc_filename = TRUE;
b91d92
         hdrcbdata->honor_cd_filename = FALSE; /* done now! */
b91d92
-        if(!tool_create_output_file(outs, TRUE))
b91d92
+        if(!tool_create_output_file(outs))
b91d92
           return failure;
b91d92
       }
b91d92
       break;
b91d92
     }
b91d92
-    if(!outs->stream && !tool_create_output_file(outs, FALSE))
b91d92
+    if(!outs->stream && !tool_create_output_file(outs))
b91d92
       return failure;
b91d92
   }
b91d92
 
b91d92
@@ -162,7 +162,7 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
b91d92
     /* bold headers only happen for HTTP(S) and RTSP */
b91d92
     char *value = NULL;
b91d92
 
b91d92
-    if(!outs->stream && !tool_create_output_file(outs, FALSE))
b91d92
+    if(!outs->stream && !tool_create_output_file(outs))
b91d92
       return failure;
b91d92
 
b91d92
     if(hdrcbdata->global->isatty && hdrcbdata->global->styled_output)
b91d92
diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c
b91d92
index 2cb5e1b..195d6e7 100644
b91d92
--- a/src/tool_cb_wrt.c
b91d92
+++ b/src/tool_cb_wrt.c
b91d92
@@ -32,8 +32,7 @@
b91d92
 #include "memdebug.h" /* keep this as LAST include */
b91d92
 
b91d92
 /* create a local file for writing, return TRUE on success */
b91d92
-bool tool_create_output_file(struct OutStruct *outs,
b91d92
-                             bool append)
b91d92
+bool tool_create_output_file(struct OutStruct *outs)
b91d92
 {
b91d92
   struct GlobalConfig *global = outs->config->global;
b91d92
   FILE *file;
b91d92
@@ -43,7 +42,7 @@ bool tool_create_output_file(struct OutStruct *outs,
b91d92
     return FALSE;
b91d92
   }
b91d92
 
b91d92
-  if(outs->is_cd_filename && !append) {
b91d92
+  if(outs->is_cd_filename) {
b91d92
     /* don't overwrite existing files */
b91d92
     file = fopen(outs->filename, "rb");
b91d92
     if(file) {
b91d92
@@ -55,7 +54,7 @@ bool tool_create_output_file(struct OutStruct *outs,
b91d92
   }
b91d92
 
b91d92
   /* open file for writing */
b91d92
-  file = fopen(outs->filename, append?"ab":"wb");
b91d92
+  file = fopen(outs->filename, "wb");
b91d92
   if(!file) {
b91d92
     warnf(global, "Failed to create the file %s: %s\n", outs->filename,
b91d92
           strerror(errno));
b91d92
@@ -142,7 +141,7 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
b91d92
   }
b91d92
 #endif
b91d92
 
b91d92
-  if(!outs->stream && !tool_create_output_file(outs, FALSE))
b91d92
+  if(!outs->stream && !tool_create_output_file(outs))
b91d92
     return failure;
b91d92
 
b91d92
   if(is_tty && (outs->bytes < 2000) && !config->terminal_binary_ok) {
b91d92
diff --git a/src/tool_cb_wrt.h b/src/tool_cb_wrt.h
b91d92
index 51e002b..188d3ea 100644
b91d92
--- a/src/tool_cb_wrt.h
b91d92
+++ b/src/tool_cb_wrt.h
b91d92
@@ -30,7 +30,7 @@
b91d92
 size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata);
b91d92
 
b91d92
 /* create a local file for writing, return TRUE on success */
b91d92
-bool tool_create_output_file(struct OutStruct *outs, bool append);
b91d92
+bool tool_create_output_file(struct OutStruct *outs);
b91d92
 
b91d92
 #endif /* HEADER_CURL_TOOL_CB_WRT_H */
b91d92
 
b91d92
diff --git a/src/tool_operate.c b/src/tool_operate.c
b91d92
index e53a9d8..429e9cf 100644
b91d92
--- a/src/tool_operate.c
b91d92
+++ b/src/tool_operate.c
b91d92
@@ -1581,7 +1581,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
b91d92
             /* do not create (or even overwrite) the file in case we get no
b91d92
                data because of unmet condition */
b91d92
             curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &cond_unmet);
b91d92
-            if(!cond_unmet && !tool_create_output_file(&outs, FALSE))
b91d92
+            if(!cond_unmet && !tool_create_output_file(&outs))
b91d92
               result = CURLE_WRITE_ERROR;
b91d92
           }
b91d92
 
b91d92
-- 
b91d92
2.17.2
b91d92