Move addPermRoot into Store
This commit is contained in:
		
							parent
							
								
									fd205fb6f8
								
							
						
					
					
						commit
						ae4a3cfa03
					
				
					 5 changed files with 15 additions and 16 deletions
				
			
		|  | @ -83,7 +83,7 @@ void LocalStore::addIndirectRoot(const Path & path) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| Path addPermRoot(ref<Store> store, const Path & _storePath, | Path Store::addPermRoot(const Path & _storePath, | ||||||
|     const Path & _gcRoot, bool indirect, bool allowOutsideRootsDir) |     const Path & _gcRoot, bool indirect, bool allowOutsideRootsDir) | ||||||
| { | { | ||||||
|     Path storePath(canonPath(_storePath)); |     Path storePath(canonPath(_storePath)); | ||||||
|  | @ -101,7 +101,7 @@ Path addPermRoot(ref<Store> store, const Path & _storePath, | ||||||
|         if (pathExists(gcRoot) && (!isLink(gcRoot) || !isInStore(readLink(gcRoot)))) |         if (pathExists(gcRoot) && (!isLink(gcRoot) || !isInStore(readLink(gcRoot)))) | ||||||
|             throw Error(format("cannot create symlink ‘%1%’; already exists") % gcRoot); |             throw Error(format("cannot create symlink ‘%1%’; already exists") % gcRoot); | ||||||
|         makeSymlink(gcRoot, storePath); |         makeSymlink(gcRoot, storePath); | ||||||
|         store->addIndirectRoot(gcRoot); |         addIndirectRoot(gcRoot); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     else { |     else { | ||||||
|  | @ -127,7 +127,7 @@ Path addPermRoot(ref<Store> store, const Path & _storePath, | ||||||
|        check if the root is in a directory in or linked from the |        check if the root is in a directory in or linked from the | ||||||
|        gcroots directory. */ |        gcroots directory. */ | ||||||
|     if (settings.checkRootReachability) { |     if (settings.checkRootReachability) { | ||||||
|         Roots roots = store->findRoots(); |         Roots roots = findRoots(); | ||||||
|         if (roots.find(gcRoot) == roots.end()) |         if (roots.find(gcRoot) == roots.end()) | ||||||
|             printMsg(lvlError, |             printMsg(lvlError, | ||||||
|                 format( |                 format( | ||||||
|  | @ -139,7 +139,7 @@ Path addPermRoot(ref<Store> store, const Path & _storePath, | ||||||
|     /* Grab the global GC root, causing us to block while a GC is in
 |     /* Grab the global GC root, causing us to block while a GC is in
 | ||||||
|        progress.  This prevents the set of permanent roots from |        progress.  This prevents the set of permanent roots from | ||||||
|        increasing while a GC is in progress. */ |        increasing while a GC is in progress. */ | ||||||
|     store->syncWithGC(); |     syncWithGC(); | ||||||
| 
 | 
 | ||||||
|     return gcRoot; |     return gcRoot; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -108,7 +108,7 @@ Path createGeneration(ref<Store> store, Path profile, Path outPath) | ||||||
|        user environment etc. we've just built. */ |        user environment etc. we've just built. */ | ||||||
|     Path generation; |     Path generation; | ||||||
|     makeName(profile, num + 1, generation); |     makeName(profile, num + 1, generation); | ||||||
|     addPermRoot(store, outPath, generation, false, true); |     store->addPermRoot(outPath, generation, false, true); | ||||||
| 
 | 
 | ||||||
|     return generation; |     return generation; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -255,6 +255,10 @@ public: | ||||||
|        `path' has disappeared. */ |        `path' has disappeared. */ | ||||||
|     virtual void addIndirectRoot(const Path & path) = 0; |     virtual void addIndirectRoot(const Path & path) = 0; | ||||||
| 
 | 
 | ||||||
|  |     /* Register a permanent GC root. */ | ||||||
|  |     Path addPermRoot(const Path & storePath, | ||||||
|  |         const Path & gcRoot, bool indirect, bool allowOutsideRootsDir = false); | ||||||
|  | 
 | ||||||
|     /* Acquire the global GC lock, then immediately release it.  This
 |     /* Acquire the global GC lock, then immediately release it.  This
 | ||||||
|        function must be called after registering a new permanent root, |        function must be called after registering a new permanent root, | ||||||
|        but before exiting.  Otherwise, it is possible that a running |        but before exiting.  Otherwise, it is possible that a running | ||||||
|  | @ -406,11 +410,6 @@ Path computeStorePathForText(const string & name, const string & s, | ||||||
| void removeTempRoots(); | void removeTempRoots(); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /* Register a permanent GC root. */ |  | ||||||
| Path addPermRoot(ref<Store> store, const Path & storePath, |  | ||||||
|     const Path & gcRoot, bool indirect, bool allowOutsideRootsDir = false); |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| /* Factory method: open the Nix database, either through the local or
 | /* Factory method: open the Nix database, either through the local or
 | ||||||
|    remote implementation. */ |    remote implementation. */ | ||||||
| ref<Store> openStore(bool reserveSpace = true); | ref<Store> openStore(bool reserveSpace = true); | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ static bool indirectRoot = false; | ||||||
| enum OutputKind { okPlain, okXML, okJSON }; | enum OutputKind { okPlain, okXML, okJSON }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| void processExpr(ref<Store> store, EvalState & state, const Strings & attrPaths, | void processExpr(EvalState & state, const Strings & attrPaths, | ||||||
|     bool parseOnly, bool strict, Bindings & autoArgs, |     bool parseOnly, bool strict, Bindings & autoArgs, | ||||||
|     bool evalOnly, OutputKind output, bool location, Expr * e) |     bool evalOnly, OutputKind output, bool location, Expr * e) | ||||||
| { | { | ||||||
|  | @ -79,7 +79,7 @@ void processExpr(ref<Store> store, EvalState & state, const Strings & attrPaths, | ||||||
|                 else { |                 else { | ||||||
|                     Path rootName = gcRoot; |                     Path rootName = gcRoot; | ||||||
|                     if (++rootNr > 1) rootName += "-" + std::to_string(rootNr); |                     if (++rootNr > 1) rootName += "-" + std::to_string(rootNr); | ||||||
|                     drvPath = addPermRoot(store, drvPath, rootName, indirectRoot); |                     drvPath = state.store->addPermRoot(drvPath, rootName, indirectRoot); | ||||||
|                 } |                 } | ||||||
|                 std::cout << format("%1%%2%\n") % drvPath % (outputName != "out" ? "!" + outputName : ""); |                 std::cout << format("%1%%2%\n") % drvPath % (outputName != "out" ? "!" + outputName : ""); | ||||||
|             } |             } | ||||||
|  | @ -177,7 +177,7 @@ int main(int argc, char * * argv) | ||||||
| 
 | 
 | ||||||
|         if (readStdin) { |         if (readStdin) { | ||||||
|             Expr * e = parseStdin(state); |             Expr * e = parseStdin(state); | ||||||
|             processExpr(store, state, attrPaths, parseOnly, strict, autoArgs, |             processExpr(state, attrPaths, parseOnly, strict, autoArgs, | ||||||
|                 evalOnly, outputKind, xmlOutputSourceLocation, e); |                 evalOnly, outputKind, xmlOutputSourceLocation, e); | ||||||
|         } else if (files.empty() && !fromArgs) |         } else if (files.empty() && !fromArgs) | ||||||
|             files.push_back("./default.nix"); |             files.push_back("./default.nix"); | ||||||
|  | @ -186,7 +186,7 @@ int main(int argc, char * * argv) | ||||||
|             Expr * e = fromArgs |             Expr * e = fromArgs | ||||||
|                 ? state.parseExprFromString(i, absPath(".")) |                 ? state.parseExprFromString(i, absPath(".")) | ||||||
|                 : state.parseExprFromFile(resolveExprPath(lookupFileArg(state, i))); |                 : state.parseExprFromFile(resolveExprPath(lookupFileArg(state, i))); | ||||||
|             processExpr(store, state, attrPaths, parseOnly, strict, autoArgs, |             processExpr(state, attrPaths, parseOnly, strict, autoArgs, | ||||||
|                 evalOnly, outputKind, xmlOutputSourceLocation, e); |                 evalOnly, outputKind, xmlOutputSourceLocation, e); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -84,7 +84,7 @@ static PathSet realisePath(Path path, bool build = true) | ||||||
|                 Path rootName = gcRoot; |                 Path rootName = gcRoot; | ||||||
|                 if (rootNr > 1) rootName += "-" + std::to_string(rootNr); |                 if (rootNr > 1) rootName += "-" + std::to_string(rootNr); | ||||||
|                 if (i->first != "out") rootName += "-" + i->first; |                 if (i->first != "out") rootName += "-" + i->first; | ||||||
|                 outPath = addPermRoot(ref<Store>(store), outPath, rootName, indirectRoot); |                 outPath = store->addPermRoot(outPath, rootName, indirectRoot); | ||||||
|             } |             } | ||||||
|             outputs.insert(outPath); |             outputs.insert(outPath); | ||||||
|         } |         } | ||||||
|  | @ -100,7 +100,7 @@ static PathSet realisePath(Path path, bool build = true) | ||||||
|             Path rootName = gcRoot; |             Path rootName = gcRoot; | ||||||
|             rootNr++; |             rootNr++; | ||||||
|             if (rootNr > 1) rootName += "-" + std::to_string(rootNr); |             if (rootNr > 1) rootName += "-" + std::to_string(rootNr); | ||||||
|             path = addPermRoot(ref<Store>(store), path, rootName, indirectRoot); |             path = store->addPermRoot(path, rootName, indirectRoot); | ||||||
|         } |         } | ||||||
|         return singleton<PathSet>(path); |         return singleton<PathSet>(path); | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue