Fix 32-bit overflow with --no-net
--no-net causes tarballTtl to be set to the largest 32-bit integer, which causes comparison like 'time + tarballTtl < other_time' to fail on 32-bit systems. So cast them to 64-bit first. https://hydra.nixos.org/build/95076624 (cherry picked from commit 29ccb2e9697ee2184012dd13854e487928ae4441)
This commit is contained in:
		
							parent
							
								
									f8b30338ac
								
							
						
					
					
						commit
						64ec087f58
					
				
					 3 changed files with 7 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -116,7 +116,7 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
 | 
			
		|||
           git fetch to update the local ref to the remote ref. */
 | 
			
		||||
        struct stat st;
 | 
			
		||||
        doFetch = stat(localRefFile.c_str(), &st) != 0 ||
 | 
			
		||||
            st.st_mtime + settings.tarballTtl <= now;
 | 
			
		||||
            (uint64_t) st.st_mtime + settings.tarballTtl <= (uint64_t) now;
 | 
			
		||||
    }
 | 
			
		||||
    if (doFetch)
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,7 +80,7 @@ HgInfo exportMercurial(ref<Store> store, const std::string & uri,
 | 
			
		|||
    time_t now = time(0);
 | 
			
		||||
    struct stat st;
 | 
			
		||||
    if (stat(stampFile.c_str(), &st) != 0 ||
 | 
			
		||||
        st.st_mtime + settings.tarballTtl <= now)
 | 
			
		||||
        (uint64_t) st.st_mtime + settings.tarballTtl <= (uint64_t) now)
 | 
			
		||||
    {
 | 
			
		||||
        /* Except that if this is a commit hash that we already have,
 | 
			
		||||
           we don't have to pull again. */
 | 
			
		||||
| 
						 | 
				
			
			@ -96,17 +96,14 @@ HgInfo exportMercurial(ref<Store> store, const std::string & uri,
 | 
			
		|||
                try {
 | 
			
		||||
                    runProgram("hg", true, { "pull", "-R", cacheDir, "--", uri });
 | 
			
		||||
                }
 | 
			
		||||
                catch (ExecError & e){
 | 
			
		||||
                catch (ExecError & e) {
 | 
			
		||||
                    string transJournal = cacheDir + "/.hg/store/journal";
 | 
			
		||||
                    /* hg throws "abandoned transaction" error only if this file exists */
 | 
			
		||||
                    if (pathExists(transJournal))
 | 
			
		||||
                    {
 | 
			
		||||
                    if (pathExists(transJournal)) {
 | 
			
		||||
                        runProgram("hg", true, { "recover", "-R", cacheDir });
 | 
			
		||||
                        runProgram("hg", true, { "pull", "-R", cacheDir, "--", uri });
 | 
			
		||||
                    }
 | 
			
		||||
                    else 
 | 
			
		||||
                    {
 | 
			
		||||
                        throw ExecError(e.status, fmt("program hg '%1%' ", statusToString(e.status)));
 | 
			
		||||
                    } else {
 | 
			
		||||
                        throw ExecError(e.status, fmt("'hg pull' %s", statusToString(e.status)));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -784,7 +784,7 @@ CachedDownloadResult Downloader::downloadCached(
 | 
			
		|||
            auto ss = tokenizeString<vector<string>>(readFile(dataFile), "\n");
 | 
			
		||||
            if (ss.size() >= 3 && ss[0] == url) {
 | 
			
		||||
                time_t lastChecked;
 | 
			
		||||
                if (string2Int(ss[2], lastChecked) && lastChecked + request.ttl >= time(0)) {
 | 
			
		||||
                if (string2Int(ss[2], lastChecked) && (uint64_t) lastChecked + request.ttl >= (uint64_t) time(0)) {
 | 
			
		||||
                    skip = true;
 | 
			
		||||
                    result.effectiveUri = request.uri;
 | 
			
		||||
                    result.etag = ss[1];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue