hi there,
i really like to have downloaded contents to have the same mtime as remote
file (when provided in Last-Modified header, for example). cclive seems to
lack this option right now. i've created a simple patch (against v0.7.11,
but should not be hard to adopt to 0.9+ i guess), have a look. i've been
using it for some time now, seems to work fine.
%%%
--- orig/cclive-0.7.11/src/cc/file.cpp 2012-12-12 21:12:49.000000000 +0800
+++ mtime/cclive-0.7.11/src/cc/file.cpp 2013-07-20 16:20:30.000000000 +0800
@@ -201,6 +201,9 @@ bool file::write(const quvi::query& q,
curl_off_t resume_from = static_cast<curl_off_t>(_initial_length);
curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, resume_from);
+ if (map.count("timestamp"))
+ curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
+
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT,
map["connect-timeout"].as<int>());
@@ -233,6 +236,7 @@ bool file::write(const quvi::query& q,
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, 0L);
+ curl_easy_setopt(curl, CURLOPT_FILETIME, 0L);
curl_easy_setopt(curl,
CURLOPT_MAX_RECV_SPEED_LARGE,
static_cast<curl_off_t>(0L));
@@ -240,6 +244,18 @@ bool file::write(const quvi::query& q,
out.flush();
out.close();
+ if (map.count("timestamp")) {
+ // Ask libcurl if we got a remote file time
+ long filetime = -1;
+ curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
+ if (filetime >= 0) {
+ struct timeval times[2];
+ times[0].tv_sec = times[1].tv_sec = (time_t)filetime;
+ times[0].tv_usec = times[1].tv_usec = (suseconds_t)0;
+ utimes(_path.c_str(), times);
+ }
+ }
+
long resp_code = 0;
long conn_code = 0;
--- orig/cclive-0.7.11/src/cc/options.cpp 2012-12-12 21:12:49.000000000
+0800
+++ mtime/cclive-0.7.11/src/cc/options.cpp 2013-07-20 15:57:45.000000000
+0800
@@ -89,6 +89,8 @@ void options::exec(int argc, char **argv
"Download media format")
("continue,c",
"Resume partially downloaded media")
+ ("timestamp,N",
+ "Try to preserve modification time")
("overwrite,W",
"Overwrite existing media")
("output-file,O",
%%%
./danfe
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
cclive-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cclive-devel