fetchGit: use a better caching scheme
The current usage technically works by putting multiple different repos in to the same git directory. However, it is very slow as Git tries very hard to find common commits between the two repositories. If the two repositories are large (like Nixpkgs and another long-running project,) it is maddeningly slow. This change busts the cache for existing deployments, but users will be promptly repaid in per-repository performance.
This commit is contained in:
		
							parent
							
								
									d277442df5
								
							
						
					
					
						commit
						02098d2073
					
				
					 2 changed files with 5 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -3,6 +3,7 @@
 | 
			
		|||
#include "download.hh"
 | 
			
		||||
#include "store-api.hh"
 | 
			
		||||
#include "pathlocks.hh"
 | 
			
		||||
#include "hash.hh"
 | 
			
		||||
 | 
			
		||||
#include <sys/time.h>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -84,9 +85,10 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
 | 
			
		|||
    if (rev != "" && !std::regex_match(rev, revRegex))
 | 
			
		||||
        throw Error("invalid Git revision '%s'", rev);
 | 
			
		||||
 | 
			
		||||
    Path cacheDir = getCacheDir() + "/nix/git";
 | 
			
		||||
    Path cacheDir = getCacheDir() + "/nix/gitv2/" + hashString(htSHA256, uri).to_string(Base32, false);
 | 
			
		||||
 | 
			
		||||
    if (!pathExists(cacheDir)) {
 | 
			
		||||
        createDirs(dirOf(cacheDir));
 | 
			
		||||
        runProgram("git", true, { "init", "--bare", cacheDir });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue