* Move root finding from nix-collect-garbage' to nix-store --gc'.
				
					
				
			This was necessary becase root finding must be done after acquisition of the global GC lock. This makes `nix-collect-garbage' obsolete; it is now just a wrapper around `nix-store --gc'. * Automatically remove stale GC roots (i.e., indirect GC roots that point to non-existent paths).
This commit is contained in:
		
							parent
							
								
									630ae0c9d7
								
							
						
					
					
						commit
						65b6c8ab4c
					
				
					 4 changed files with 75 additions and 111 deletions
				
			
		|  | @ -38,9 +38,7 @@ static Path followSymlinks(Path & path) | |||
|     while (!isStorePath(path)) { | ||||
|         if (!isLink(path)) return path; | ||||
|         string target = readLink(path); | ||||
|         path = canonPath(string(target, 0, 1) == "/" | ||||
|             ? target | ||||
|             : path + "/" + target); | ||||
|         path = absPath(target, dirOf(path)); | ||||
|     } | ||||
|     return path; | ||||
| } | ||||
|  | @ -308,27 +306,19 @@ static void opIsValid(Strings opFlags, Strings opArgs) | |||
| 
 | ||||
| static void opGC(Strings opFlags, Strings opArgs) | ||||
| { | ||||
|     GCAction action; | ||||
|     GCAction action = gcDeleteDead; | ||||
|      | ||||
|     /* Do what? */ | ||||
|     for (Strings::iterator i = opFlags.begin(); | ||||
|          i != opFlags.end(); ++i) | ||||
|         if (*i == "--print-live") action = gcReturnLive; | ||||
|         if (*i == "--print-roots") action = gcReturnRoots; | ||||
|         else if (*i == "--print-live") action = gcReturnLive; | ||||
|         else if (*i == "--print-dead") action = gcReturnDead; | ||||
|         else if (*i == "--delete") action = gcDeleteDead; | ||||
|         else throw UsageError(format("bad sub-operation `%1%' in GC") % *i); | ||||
| 
 | ||||
|     /* Read the roots. */ | ||||
|     PathSet roots; | ||||
|     while (1) { | ||||
|         Path root; | ||||
|         getline(cin, root); | ||||
|         if (cin.eof()) break; | ||||
|         roots.insert(root); | ||||
|     } | ||||
| 
 | ||||
|     PathSet result; | ||||
|     collectGarbage(roots, action, result); | ||||
|     collectGarbage(action, result); | ||||
| 
 | ||||
|     if (action != gcDeleteDead) { | ||||
|         for (PathSet::iterator i = result.begin(); i != result.end(); ++i) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue