Skip to content

Commit

Permalink
Show which path in the large path warning
Browse files Browse the repository at this point in the history
Fixes NixOS#1184.
  • Loading branch information
edolstra committed Apr 9, 2018
1 parent c94b4fc commit 7c1db07
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
1 change: 1 addition & 0 deletions src/libstore/local-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,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());
Expand Down
20 changes: 0 additions & 20 deletions src/libutil/serialise.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -299,11 +284,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);
}

Expand Down

0 comments on commit 7c1db07

Please sign in to comment.