* When doing "nix-store --add-fixed" without "--recursive" via the Nix
daemon (which is an error), print a nicer error message than "Connection reset by peer" or "broken pipe". * In the daemon, log errors that occur during request parameter processing.
This commit is contained in:
parent
be9be4c147
commit
24f863d86b
|
@ -151,9 +151,7 @@ public:
|
||||||
|
|
||||||
/* Copy the contents of a path to the store and register the
|
/* Copy the contents of a path to the store and register the
|
||||||
validity the resulting path. The resulting path is returned.
|
validity the resulting path. The resulting path is returned.
|
||||||
If `fixed' is true, then the output of a fixed-output
|
The function object `filter' can be used to exclude files (see
|
||||||
derivation is pre-loaded into the Nix store. The function
|
|
||||||
object `filter' can be used to exclude files (see
|
|
||||||
libutil/archive.hh). */
|
libutil/archive.hh). */
|
||||||
virtual Path addToStore(const Path & srcPath,
|
virtual Path addToStore(const Path & srcPath,
|
||||||
bool recursive = true, HashType hashAlgo = htSHA256,
|
bool recursive = true, HashType hashAlgo = htSHA256,
|
||||||
|
|
|
@ -241,11 +241,14 @@ struct TunnelSource : Source
|
||||||
the contents of the file to `s'. Otherwise barf. */
|
the contents of the file to `s'. Otherwise barf. */
|
||||||
struct RetrieveRegularNARSink : ParseSink
|
struct RetrieveRegularNARSink : ParseSink
|
||||||
{
|
{
|
||||||
|
bool regular;
|
||||||
string s;
|
string s;
|
||||||
|
|
||||||
|
RetrieveRegularNARSink() : regular(true) { }
|
||||||
|
|
||||||
void createDirectory(const Path & path)
|
void createDirectory(const Path & path)
|
||||||
{
|
{
|
||||||
throw Error("regular file expected");
|
regular = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void receiveContents(unsigned char * data, unsigned int len)
|
void receiveContents(unsigned char * data, unsigned int len)
|
||||||
|
@ -255,7 +258,7 @@ struct RetrieveRegularNARSink : ParseSink
|
||||||
|
|
||||||
void createSymlink(const Path & path, const string & target)
|
void createSymlink(const Path & path, const string & target)
|
||||||
{
|
{
|
||||||
throw Error("regular file expected");
|
regular = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -363,6 +366,7 @@ static void performOp(unsigned int clientVersion,
|
||||||
parseDump(sink, savedNAR);
|
parseDump(sink, savedNAR);
|
||||||
} else {
|
} else {
|
||||||
parseDump(savedRegular, from);
|
parseDump(savedRegular, from);
|
||||||
|
if (!savedRegular.regular) throw Error("regular file expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
startWork();
|
startWork();
|
||||||
|
@ -638,7 +642,15 @@ static void processConnection()
|
||||||
try {
|
try {
|
||||||
performOp(clientVersion, from, to, op);
|
performOp(clientVersion, from, to, op);
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
|
/* If we're not in a state were we can send replies, then
|
||||||
|
something went wrong processing the input of the
|
||||||
|
client. This can happen especially if I/O errors occur
|
||||||
|
during addTextToStore() / importPath(). If that
|
||||||
|
happens, just send the error message and exit. */
|
||||||
|
bool errorAllowed = canSendStderr;
|
||||||
|
if (!errorAllowed) printMsg(lvlError, format("error processing client input: %1%") % e.msg());
|
||||||
stopWork(false, e.msg(), GET_PROTOCOL_MINOR(clientVersion) >= 8 ? e.status : 0);
|
stopWork(false, e.msg(), GET_PROTOCOL_MINOR(clientVersion) >= 8 ? e.status : 0);
|
||||||
|
if (!errorAllowed) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!canSendStderr);
|
assert(!canSendStderr);
|
||||||
|
|
Loading…
Reference in a new issue