Fix NarInfoDiskCache::queryCacheRaw on 32 bit platforms
Bug has existed for a long time, but was only recently surfaced by
6733f2e5ce. time_t was being implicitly promoted
to unsigned. Apparently time_t is still 32 bit for i686-linux in nixpkgs.
Fixes https://hydra.nixos.org/build/322992746/nixlog/1
This commit is contained in:
@@ -181,7 +181,11 @@ private:
|
||||
{
|
||||
auto i = state.caches.find(uri);
|
||||
if (i == state.caches.end()) {
|
||||
auto queryCache(state.queryCache.use()(uri)(time(0) - settings.ttlMeta));
|
||||
/* Important: always use int64_t even on 32 bit systems. Otherwise
|
||||
the the subtraction would promote time_t to unsigned if time_t is
|
||||
32 bit. */
|
||||
auto timestamp = static_cast<int64_t>(time(nullptr)) - static_cast<int64_t>(settings.ttlMeta.get());
|
||||
auto queryCache(state.queryCache.use()(uri)(timestamp));
|
||||
if (!queryCache.next())
|
||||
return std::nullopt;
|
||||
auto cache = Cache{
|
||||
|
||||
Reference in New Issue
Block a user