gnuplot: Bump revision after libgd update
[termux-packages] / packages / newsbeuter / 010_podbeuter_redownload.patch
CommitLineData
4a77e94d
BK
1From c841c4a7871d2f79f9b7e2d53734f55e8410e231 Mon Sep 17 00:00:00 2001
2From: Alexander Batischev <eual.jp@gmail.com>
3Date: Fri, 22 Jan 2016 22:55:48 +0300
4Subject: [PATCH] Re-download, not delete, existing files. Fixes #169
5
6---
7 include/poddlthread.h | 1 +
8 src/poddlthread.cpp | 19 +++++++++++++++++--
9 2 files changed, 18 insertions(+), 2 deletions(-)
10
11diff --git a/include/poddlthread.h b/include/poddlthread.h
12index cf0f1da..99299f3 100644
13--- a/include/poddlthread.h
14+++ b/include/poddlthread.h
15@@ -23,6 +23,7 @@ class poddlthread {
16 protected:
17 double compute_kbps();
18 private:
19+ void run();
20 void mkdir_p(const char * file);
21 download * dl;
22 std::shared_ptr<std::ofstream> f;
23diff --git a/src/poddlthread.cpp b/src/poddlthread.cpp
24index 3a1b390..afa6762 100644
25--- a/src/poddlthread.cpp
26+++ b/src/poddlthread.cpp
27@@ -25,6 +25,13 @@ poddlthread::~poddlthread() {
28 }
29
30 void poddlthread::operator()() {
31+ run();
32+}
33+
34+void poddlthread::run() {
35+ // are we resuming previous download?
36+ bool resumed_download = false;
37+
38 gettimeofday(&tv1, NULL);
39 ++bytecount;
40
41@@ -55,11 +62,13 @@ void poddlthread::operator()() {
42 mkdir_p(dl->filename());
43 f->open(dl->filename(), std::fstream::out);
44 dl->set_offset(0);
45+ resumed_download = false;
46 } else {
47 LOG(LOG_INFO, "poddlthread::run: stat ok: starting download from %u", sb.st_size);
48 curl_easy_setopt(easyhandle, CURLOPT_RESUME_FROM, sb.st_size);
49 dl->set_offset(sb.st_size);
50 f->open(dl->filename(), std::fstream::out | std::fstream::app);
51+ resumed_download = true;
52 }
53
54 if (f->is_open()) {
55@@ -75,8 +84,14 @@ void poddlthread::operator()() {
56 if (0 == success)
57 dl->set_status(DL_READY);
58 else if (dl->status() != DL_CANCELLED) {
59- dl->set_status(DL_FAILED);
60- ::unlink(dl->filename());
61+ // attempt complete re-download
62+ if (resumed_download) {
63+ ::unlink(dl->filename());
64+ this->run();
65+ } else {
66+ dl->set_status(DL_FAILED);
67+ ::unlink(dl->filename());
68+ }
69 }
70 } else {
71 dl->set_status(DL_FAILED);