* Support exportPath() in remote mode.
This commit is contained in:
		
							parent
							
								
									dc7d594776
								
							
						
					
					
						commit
						0f5da8a83c
					
				
					 4 changed files with 42 additions and 5 deletions
				
			
		| 
						 | 
					@ -246,7 +246,11 @@ Path RemoteStore::addTextToStore(const string & suffix, const string & s,
 | 
				
			||||||
void RemoteStore::exportPath(const Path & path, bool sign,
 | 
					void RemoteStore::exportPath(const Path & path, bool sign,
 | 
				
			||||||
    Sink & sink)
 | 
					    Sink & sink)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    throw Error("not implemented");
 | 
					    writeInt(wopExportPath, to);
 | 
				
			||||||
 | 
					    writeString(path, to);
 | 
				
			||||||
 | 
					    writeInt(sign ? 1 : 0, to);
 | 
				
			||||||
 | 
					    processStderr(&sink); /* sink receives the actual data */
 | 
				
			||||||
 | 
					    readInt(from);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -336,12 +340,16 @@ void RemoteStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void RemoteStore::processStderr()
 | 
					void RemoteStore::processStderr(Sink * sink)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    unsigned int msg;
 | 
					    unsigned int msg;
 | 
				
			||||||
    while ((msg = readInt(from)) == STDERR_NEXT) {
 | 
					    while ((msg = readInt(from)) == STDERR_NEXT || msg == STDERR_DATA) {
 | 
				
			||||||
        string s = readString(from);
 | 
					        string s = readString(from);
 | 
				
			||||||
        writeToStderr((unsigned char *) s.c_str(), s.size());
 | 
					        if (msg == STDERR_DATA) {
 | 
				
			||||||
 | 
					            if (!sink) throw Error("no sink");
 | 
				
			||||||
 | 
					            (*sink)((const unsigned char *) s.c_str(), s.size());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else writeToStderr((const unsigned char *) s.c_str(), s.size());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (msg == STDERR_ERROR)
 | 
					    if (msg == STDERR_ERROR)
 | 
				
			||||||
        throw Error(readString(from));
 | 
					        throw Error(readString(from));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -70,7 +70,7 @@ private:
 | 
				
			||||||
    FdSource from;
 | 
					    FdSource from;
 | 
				
			||||||
    Pid child;
 | 
					    Pid child;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void processStderr();
 | 
					    void processStderr(Sink * sink = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void forkSlave();
 | 
					    void forkSlave();
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,10 +26,13 @@ typedef enum {
 | 
				
			||||||
    wopSyncWithGC,
 | 
					    wopSyncWithGC,
 | 
				
			||||||
    wopFindRoots,
 | 
					    wopFindRoots,
 | 
				
			||||||
    wopCollectGarbage,
 | 
					    wopCollectGarbage,
 | 
				
			||||||
 | 
					    wopExportPath,
 | 
				
			||||||
 | 
					    wopImportPath,
 | 
				
			||||||
} WorkerOp;
 | 
					} WorkerOp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define STDERR_NEXT  0x6f6c6d67
 | 
					#define STDERR_NEXT  0x6f6c6d67
 | 
				
			||||||
 | 
					#define STDERR_DATA  0x64617461
 | 
				
			||||||
#define STDERR_LAST  0x616c7473
 | 
					#define STDERR_LAST  0x616c7473
 | 
				
			||||||
#define STDERR_ERROR 0x63787470
 | 
					#define STDERR_ERROR 0x63787470
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -178,6 +178,21 @@ static void stopWork(bool success = true, const string & msg = "")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct TunnelSink : Sink
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    Sink & to;
 | 
				
			||||||
 | 
					    TunnelSink(Sink & to) : to(to)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    virtual void operator ()
 | 
				
			||||||
 | 
					        (const unsigned char * data, unsigned int len)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        writeInt(STDERR_DATA, to);
 | 
				
			||||||
 | 
					        writeString(string((const char *) data, len), to);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void performOp(Source & from, Sink & to, unsigned int op)
 | 
					static void performOp(Source & from, Sink & to, unsigned int op)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    switch (op) {
 | 
					    switch (op) {
 | 
				
			||||||
| 
						 | 
					@ -263,6 +278,17 @@ static void performOp(Source & from, Sink & to, unsigned int op)
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    case wopExportPath: {
 | 
				
			||||||
 | 
					        Path path = readStorePath(from);
 | 
				
			||||||
 | 
					        bool sign = readInt(from) == 1;
 | 
				
			||||||
 | 
					        startWork();
 | 
				
			||||||
 | 
					        TunnelSink sink(to);
 | 
				
			||||||
 | 
					        store->exportPath(path, sign, sink);
 | 
				
			||||||
 | 
					        stopWork();
 | 
				
			||||||
 | 
					        writeInt(1, to);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case wopBuildDerivations: {
 | 
					    case wopBuildDerivations: {
 | 
				
			||||||
        PathSet drvs = readStorePaths(from);
 | 
					        PathSet drvs = readStorePaths(from);
 | 
				
			||||||
        startWork();
 | 
					        startWork();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue