mirror of
				https://github.com/Swatinem/rust-cache.git
				synced 2025-10-31 19:33:48 +00:00 
			
		
		
		
	move target clean
This commit is contained in:
		
							parent
							
								
									3231cccdde
								
							
						
					
					
						commit
						0381560ff9
					
				
							
								
								
									
										54
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										54
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							| @ -87075,35 +87075,35 @@ async function cleanProfileTarget(profileDir, packages, checkTimestamp, incremen | ||||
|         } | ||||
|         catch { } | ||||
|         // Delete everything else.
 | ||||
|         let except = new Set(["target", "trybuild"]); | ||||
|         // Keep the incremental folder if incremental builds are enabled
 | ||||
|         if (incremental) { | ||||
|             except.add("incremental"); | ||||
|             // Traverse the incremental folder recursively and collect the modified times in a map
 | ||||
|             const incrementalDir = external_path_default().join(profileDir, "incremental"); | ||||
|             const modifiedTimes = new Map(); | ||||
|             const fillModifiedTimes = async (dir) => { | ||||
|                 const dirEntries = await external_fs_default().promises.opendir(dir); | ||||
|                 for await (const dirent of dirEntries) { | ||||
|                     if (dirent.isDirectory()) { | ||||
|                         await fillModifiedTimes(external_path_default().join(dir, dirent.name)); | ||||
|                     } | ||||
|                     else { | ||||
|                         const fileName = external_path_default().join(dir, dirent.name); | ||||
|                         const { mtime } = await external_fs_default().promises.stat(fileName); | ||||
|                         modifiedTimes.set(fileName, mtime.getTime()); | ||||
|                     } | ||||
|                 } | ||||
|             }; | ||||
|             await fillModifiedTimes(incrementalDir); | ||||
|             // Write the modified times to the incremental folder
 | ||||
|             const contents = JSON.stringify({ modifiedTimes }); | ||||
|             await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents); | ||||
|         } | ||||
|         await rmExcept(profileDir, except, checkTimestamp); | ||||
|         await rmExcept(profileDir, new Set(["target", "trybuild"]), checkTimestamp); | ||||
|         return; | ||||
|     } | ||||
|     let keepProfile = new Set(["build", ".fingerprint", "deps"]); | ||||
|     // Keep the incremental folder if incremental builds are enabled
 | ||||
|     if (incremental) { | ||||
|         keepProfile.add("incremental"); | ||||
|         // Traverse the incremental folder recursively and collect the modified times in a map
 | ||||
|         const incrementalDir = external_path_default().join(profileDir, "incremental"); | ||||
|         const modifiedTimes = new Map(); | ||||
|         const fillModifiedTimes = async (dir) => { | ||||
|             const dirEntries = await external_fs_default().promises.opendir(dir); | ||||
|             for await (const dirent of dirEntries) { | ||||
|                 if (dirent.isDirectory()) { | ||||
|                     await fillModifiedTimes(external_path_default().join(dir, dirent.name)); | ||||
|                 } | ||||
|                 else { | ||||
|                     const fileName = external_path_default().join(dir, dirent.name); | ||||
|                     const { mtime } = await external_fs_default().promises.stat(fileName); | ||||
|                     modifiedTimes.set(fileName, mtime.getTime()); | ||||
|                 } | ||||
|             } | ||||
|         }; | ||||
|         await fillModifiedTimes(incrementalDir); | ||||
|         // Write the modified times to the incremental folder
 | ||||
|         lib_core.debug(`writing incremental-restore.json for ${incrementalDir} with ${modifiedTimes} files`); | ||||
|         const contents = JSON.stringify({ modifiedTimes }); | ||||
|         await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents); | ||||
|     } | ||||
|     await rmExcept(profileDir, keepProfile); | ||||
|     const keepPkg = new Set(packages.map((p) => p.name)); | ||||
|     await rmExcept(external_path_default().join(profileDir, "build"), keepPkg, checkTimestamp); | ||||
| @ -87437,7 +87437,7 @@ async function run() { | ||||
|                 // pre-clean the target directory on cache mismatch
 | ||||
|                 for (const workspace of config.workspaces) { | ||||
|                     try { | ||||
|                         await cleanTargetDir(workspace.target, [], true, false); | ||||
|                         await cleanTargetDir(workspace.target, [], true, config.incremental); | ||||
|                     } | ||||
|                     catch { } | ||||
|                 } | ||||
|  | ||||
							
								
								
									
										52
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										52
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							| @ -87075,35 +87075,35 @@ async function cleanProfileTarget(profileDir, packages, checkTimestamp, incremen | ||||
|         } | ||||
|         catch { } | ||||
|         // Delete everything else.
 | ||||
|         let except = new Set(["target", "trybuild"]); | ||||
|         // Keep the incremental folder if incremental builds are enabled
 | ||||
|         if (incremental) { | ||||
|             except.add("incremental"); | ||||
|             // Traverse the incremental folder recursively and collect the modified times in a map
 | ||||
|             const incrementalDir = external_path_default().join(profileDir, "incremental"); | ||||
|             const modifiedTimes = new Map(); | ||||
|             const fillModifiedTimes = async (dir) => { | ||||
|                 const dirEntries = await external_fs_default().promises.opendir(dir); | ||||
|                 for await (const dirent of dirEntries) { | ||||
|                     if (dirent.isDirectory()) { | ||||
|                         await fillModifiedTimes(external_path_default().join(dir, dirent.name)); | ||||
|                     } | ||||
|                     else { | ||||
|                         const fileName = external_path_default().join(dir, dirent.name); | ||||
|                         const { mtime } = await external_fs_default().promises.stat(fileName); | ||||
|                         modifiedTimes.set(fileName, mtime.getTime()); | ||||
|                     } | ||||
|                 } | ||||
|             }; | ||||
|             await fillModifiedTimes(incrementalDir); | ||||
|             // Write the modified times to the incremental folder
 | ||||
|             const contents = JSON.stringify({ modifiedTimes }); | ||||
|             await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents); | ||||
|         } | ||||
|         await rmExcept(profileDir, except, checkTimestamp); | ||||
|         await rmExcept(profileDir, new Set(["target", "trybuild"]), checkTimestamp); | ||||
|         return; | ||||
|     } | ||||
|     let keepProfile = new Set(["build", ".fingerprint", "deps"]); | ||||
|     // Keep the incremental folder if incremental builds are enabled
 | ||||
|     if (incremental) { | ||||
|         keepProfile.add("incremental"); | ||||
|         // Traverse the incremental folder recursively and collect the modified times in a map
 | ||||
|         const incrementalDir = external_path_default().join(profileDir, "incremental"); | ||||
|         const modifiedTimes = new Map(); | ||||
|         const fillModifiedTimes = async (dir) => { | ||||
|             const dirEntries = await external_fs_default().promises.opendir(dir); | ||||
|             for await (const dirent of dirEntries) { | ||||
|                 if (dirent.isDirectory()) { | ||||
|                     await fillModifiedTimes(external_path_default().join(dir, dirent.name)); | ||||
|                 } | ||||
|                 else { | ||||
|                     const fileName = external_path_default().join(dir, dirent.name); | ||||
|                     const { mtime } = await external_fs_default().promises.stat(fileName); | ||||
|                     modifiedTimes.set(fileName, mtime.getTime()); | ||||
|                 } | ||||
|             } | ||||
|         }; | ||||
|         await fillModifiedTimes(incrementalDir); | ||||
|         // Write the modified times to the incremental folder
 | ||||
|         core.debug(`writing incremental-restore.json for ${incrementalDir} with ${modifiedTimes} files`); | ||||
|         const contents = JSON.stringify({ modifiedTimes }); | ||||
|         await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents); | ||||
|     } | ||||
|     await rmExcept(profileDir, keepProfile); | ||||
|     const keepPkg = new Set(packages.map((p) => p.name)); | ||||
|     await rmExcept(external_path_default().join(profileDir, "build"), keepPkg, checkTimestamp); | ||||
|  | ||||
| @ -51,40 +51,39 @@ async function cleanProfileTarget(profileDir: string, packages: Packages, checkT | ||||
|     } catch { } | ||||
| 
 | ||||
|     // Delete everything else.
 | ||||
|     let except = new Set(["target", "trybuild"]); | ||||
| 
 | ||||
|     // Keep the incremental folder if incremental builds are enabled
 | ||||
|     if (incremental) { | ||||
|       except.add("incremental"); | ||||
| 
 | ||||
|       // Traverse the incremental folder recursively and collect the modified times in a map
 | ||||
|       const incrementalDir = path.join(profileDir, "incremental"); | ||||
|       const modifiedTimes = new Map<string, number>(); | ||||
|       const fillModifiedTimes = async (dir: string) => { | ||||
|         const dirEntries = await fs.promises.opendir(dir); | ||||
|         for await (const dirent of dirEntries) { | ||||
|           if (dirent.isDirectory()) { | ||||
|             await fillModifiedTimes(path.join(dir, dirent.name)); | ||||
|           } else { | ||||
|             const fileName = path.join(dir, dirent.name); | ||||
|             const { mtime } = await fs.promises.stat(fileName); | ||||
|             modifiedTimes.set(fileName, mtime.getTime()); | ||||
|           } | ||||
|         } | ||||
|       }; | ||||
|       await fillModifiedTimes(incrementalDir); | ||||
| 
 | ||||
|       // Write the modified times to the incremental folder
 | ||||
|       const contents = JSON.stringify({ modifiedTimes }); | ||||
|       await fs.promises.writeFile(path.join(incrementalDir, "incremental-restore.json"), contents); | ||||
|     } | ||||
| 
 | ||||
|     await rmExcept(profileDir, except, checkTimestamp); | ||||
| 
 | ||||
|     await rmExcept(profileDir, new Set(["target", "trybuild"]), checkTimestamp); | ||||
|     return; | ||||
|   } | ||||
| 
 | ||||
|   let keepProfile = new Set(["build", ".fingerprint", "deps"]); | ||||
| 
 | ||||
|   // Keep the incremental folder if incremental builds are enabled
 | ||||
|   if (incremental) { | ||||
|     keepProfile.add("incremental"); | ||||
| 
 | ||||
|     // Traverse the incremental folder recursively and collect the modified times in a map
 | ||||
|     const incrementalDir = path.join(profileDir, "incremental"); | ||||
|     const modifiedTimes = new Map<string, number>(); | ||||
|     const fillModifiedTimes = async (dir: string) => { | ||||
|       const dirEntries = await fs.promises.opendir(dir); | ||||
|       for await (const dirent of dirEntries) { | ||||
|         if (dirent.isDirectory()) { | ||||
|           await fillModifiedTimes(path.join(dir, dirent.name)); | ||||
|         } else { | ||||
|           const fileName = path.join(dir, dirent.name); | ||||
|           const { mtime } = await fs.promises.stat(fileName); | ||||
|           modifiedTimes.set(fileName, mtime.getTime()); | ||||
|         } | ||||
|       } | ||||
|     }; | ||||
|     await fillModifiedTimes(incrementalDir); | ||||
| 
 | ||||
|     // Write the modified times to the incremental folder
 | ||||
|     core.debug(`writing incremental-restore.json for ${incrementalDir} with ${modifiedTimes} files`); | ||||
|     const contents = JSON.stringify({ modifiedTimes }); | ||||
|     await fs.promises.writeFile(path.join(incrementalDir, "incremental-restore.json"), contents); | ||||
|   } | ||||
| 
 | ||||
|   await rmExcept(profileDir, keepProfile); | ||||
| 
 | ||||
|   const keepPkg = new Set(packages.map((p) => p.name)); | ||||
|  | ||||
| @ -60,7 +60,7 @@ async function run() { | ||||
|         // pre-clean the target directory on cache mismatch
 | ||||
|         for (const workspace of config.workspaces) { | ||||
|           try { | ||||
|             await cleanTargetDir(workspace.target, [], true, false); | ||||
|             await cleanTargetDir(workspace.target, [], true, config.incremental); | ||||
|           } catch { } | ||||
|         } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user