Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=e57d5d62f29463e976cec2d44a59f4e4bc52f16d
commit e57d5d62f29463e976cec2d44a59f4e4bc52f16d Author: Michel Hermier <[email protected]> Date: Fri Aug 1 23:42:14 2014 +0200 libpacman: Fix getting downloaded file time stamp. diff --git a/lib/libpacman/server.cpp b/lib/libpacman/server.cpp index c12f3aa..1376fe6 100644 --- a/lib/libpacman/server.cpp +++ b/lib/libpacman/server.cpp @@ -323,9 +323,12 @@ again: //also check for download size as in some cases (proxy) ret codes won't work ret = PM_DOWNLOAD_OK_CACHE; } else { - if(curl_easy_getinfo(curlHandle, CURLINFO_FILETIME, mtime2) != CURLE_OK) { - *mtime2 = PM_TIME_INVALID; + long filetime = PM_TIME_INVALID; + + if(curl_easy_getinfo(curlHandle, CURLINFO_FILETIME, &filetime) == CURLE_OK) { + _pacman_log(PM_LOG_DEBUG, _("cache time '%li' (epoch) for downloaded file: %s\n"), filetime, url); } + mtime2->fromEpoch(filetime); } } fclose(outputFile); diff --git a/lib/libpacman/timestamp.h b/lib/libpacman/timestamp.h index 0a5c6e1..1f32f0a 100644 --- a/lib/libpacman/timestamp.h +++ b/lib/libpacman/timestamp.h @@ -31,7 +31,7 @@ struct Timestamp : m_value(PM_TIME_INVALID) { } - Timestamp(const time_t &epoch) + explicit Timestamp(const time_t &epoch) : m_value(epoch) { } @@ -40,11 +40,21 @@ struct Timestamp return m_value == epoch; } + bool operator != (const time_t &epoch) const + { + return !operator == (epoch); + } + double operator - (const libpacman::Timestamp &other) const { return difftime(m_value, other.m_value); } + void fromEpoch(const time_t &epoch) + { + m_value = epoch; + } + bool isValid() const { return m_value != PM_TIME_INVALID; _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
