diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index e6ba0e6e4e2..ba3637991d0 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1140,6 +1140,7 @@ Path LocalStore::addToStore(const string & name, const Path & _srcPath, if (inMemory) { if (nar.size() + len > settings.narBufferSize) { + printError("warning: adding very large path '%s' to the Nix store", srcPath); inMemory = false; sink << 1; sink((const unsigned char *) nar.data(), nar.size()); diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc index 0e75eeec2bf..df6f0490137 100644 --- a/src/libutil/serialise.cc +++ b/src/libutil/serialise.cc @@ -48,24 +48,9 @@ FdSink::~FdSink() } -size_t threshold = 256 * 1024 * 1024; - -static void warnLargeDump() -{ - printError("warning: dumping very large path (> 256 MiB); this may run out of memory"); -} - - void FdSink::write(const unsigned char * data, size_t len) { written += len; - static bool warned = false; - if (warn && !warned) { - if (written > threshold) { - warnLargeDump(); - warned = true; - } - } try { writeFull(fd, data, len); } catch (SysError & e) { @@ -311,11 +296,6 @@ template PathSet readStrings(Source & source); void StringSink::operator () (const unsigned char * data, size_t len) { - static bool warned = false; - if (!warned && s->size() > threshold) { - warnLargeDump(); - warned = true; - } s->append((const char *) data, len); }