mirror of
				https://github.com/Swatinem/rust-cache
				synced 2025-11-03 22:19:10 +00:00 
			
		
		
		
	serialization bugs
This commit is contained in:
		
							parent
							
								
									5bbbdb9115
								
							
						
					
					
						commit
						829dfd6b08
					
				
					 4 changed files with 23 additions and 12 deletions
				
			
		
							
								
								
									
										1
									
								
								dist/restore/index.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								dist/restore/index.js
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -87392,6 +87392,7 @@ async function run() {
 | 
			
		|||
                    const restoreJson = external_path_default().join(config_CARGO_HOME, "incremental-restore.json");
 | 
			
		||||
                    const restoreString = await external_fs_default().promises.readFile(restoreJson, "utf8");
 | 
			
		||||
                    const restoreData = JSON.parse(restoreString);
 | 
			
		||||
                    lib_core.debug(`restoreData: ${JSON.stringify(restoreData)}`);
 | 
			
		||||
                    if (restoreData.roots.length == 0) {
 | 
			
		||||
                        throw new Error("No incremental roots found");
 | 
			
		||||
                    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										13
									
								
								dist/save/index.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								dist/save/index.js
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -87340,8 +87340,11 @@ async function rmRF(dirName) {
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
async function saveMtimes(targetDirs) {
 | 
			
		||||
    let times = new Map();
 | 
			
		||||
    let stack = new Array();
 | 
			
		||||
    let data = {
 | 
			
		||||
        roots: [],
 | 
			
		||||
        times: {},
 | 
			
		||||
    };
 | 
			
		||||
    let stack = [];
 | 
			
		||||
    // Collect all the incremental files
 | 
			
		||||
    for (const dir of targetDirs) {
 | 
			
		||||
        for (const maybeProfile of await external_fs_default().promises.readdir(dir)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -87353,7 +87356,7 @@ async function saveMtimes(targetDirs) {
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
    // Save the stack as the roots - we cache these directly
 | 
			
		||||
    let roots = stack.slice();
 | 
			
		||||
    data.roots = stack.slice();
 | 
			
		||||
    while (stack.length > 0) {
 | 
			
		||||
        const dirName = stack.pop();
 | 
			
		||||
        const dir = await external_fs_default().promises.opendir(dirName);
 | 
			
		||||
| 
						 | 
				
			
			@ -87364,11 +87367,11 @@ async function saveMtimes(targetDirs) {
 | 
			
		|||
            else {
 | 
			
		||||
                const fileName = external_path_default().join(dirName, dirent.name);
 | 
			
		||||
                const { mtime } = await external_fs_default().promises.stat(fileName);
 | 
			
		||||
                times.set(fileName, mtime.getTime());
 | 
			
		||||
                data.times[fileName] = mtime.getTime();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return { roots, times: times };
 | 
			
		||||
    return data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
;// CONCATENATED MODULE: ./src/save.ts
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,13 +8,18 @@ import fs from "fs";
 | 
			
		|||
import path from "path";
 | 
			
		||||
 | 
			
		||||
export type MtimeData = {
 | 
			
		||||
  roots: Array<string>,
 | 
			
		||||
  times: Map<string, number>
 | 
			
		||||
  roots: string[],
 | 
			
		||||
  times: {
 | 
			
		||||
    [key: string]: number
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export async function saveMtimes(targetDirs: string[]): Promise<MtimeData> {
 | 
			
		||||
  let times = new Map<string, number>();
 | 
			
		||||
  let stack = new Array<string>();
 | 
			
		||||
  let data: MtimeData = {
 | 
			
		||||
    roots: [],
 | 
			
		||||
    times: {},
 | 
			
		||||
  };
 | 
			
		||||
  let stack: string[] = [];
 | 
			
		||||
 | 
			
		||||
  // Collect all the incremental files
 | 
			
		||||
  for (const dir of targetDirs) {
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +33,7 @@ export async function saveMtimes(targetDirs: string[]): Promise<MtimeData> {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  // Save the stack as the roots - we cache these directly
 | 
			
		||||
  let roots = stack.slice();
 | 
			
		||||
  data.roots = stack.slice();
 | 
			
		||||
 | 
			
		||||
  while (stack.length > 0) {
 | 
			
		||||
    const dirName = stack.pop()!;
 | 
			
		||||
| 
						 | 
				
			
			@ -40,10 +45,10 @@ export async function saveMtimes(targetDirs: string[]): Promise<MtimeData> {
 | 
			
		|||
      } else {
 | 
			
		||||
        const fileName = path.join(dirName, dirent.name);
 | 
			
		||||
        const { mtime } = await fs.promises.stat(fileName);
 | 
			
		||||
        times.set(fileName, mtime.getTime());
 | 
			
		||||
        data.times[fileName] = mtime.getTime();
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return { roots, times: times };
 | 
			
		||||
  return data;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -71,6 +71,8 @@ async function run() {
 | 
			
		|||
          const restoreString = await fs.promises.readFile(restoreJson, "utf8");
 | 
			
		||||
          const restoreData: MtimeData = JSON.parse(restoreString);
 | 
			
		||||
 | 
			
		||||
          core.debug(`restoreData: ${JSON.stringify(restoreData)}`);
 | 
			
		||||
 | 
			
		||||
          if (restoreData.roots.length == 0) {
 | 
			
		||||
            throw new Error("No incremental roots found");
 | 
			
		||||
          }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue