mirror of
				https://github.com/Swatinem/rust-cache.git
				synced 2025-10-31 23:43:47 +00:00 
			
		
		
		
	Discard files older than 3 days from cache
This commit is contained in:
		
							parent
							
								
									3abbfe0f3f
								
							
						
					
					
						commit
						2f124887c3
					
				
							
								
								
									
										4
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							| @ -87258,7 +87258,7 @@ async function cleanGit(packages) { | |||||||
|     } |     } | ||||||
|     catch { } |     catch { } | ||||||
| } | } | ||||||
| const ONE_WEEK = 7 * 24 * 3600 * 1000; | const THREE_DAYS = 3 * 24 * 3600 * 1000; | ||||||
| /** | /** | ||||||
|  * Removes all files or directories in `dirName` matching some criteria. |  * Removes all files or directories in `dirName` matching some criteria. | ||||||
|  * |  * | ||||||
| @ -87275,7 +87275,7 @@ async function rmExcept(dirName, keepPrefix, checkTimestamp = false) { | |||||||
|         if (checkTimestamp) { |         if (checkTimestamp) { | ||||||
|             const fileName = external_path_default().join(dir.path, dirent.name); |             const fileName = external_path_default().join(dir.path, dirent.name); | ||||||
|             const { mtime } = await external_fs_default().promises.stat(fileName); |             const { mtime } = await external_fs_default().promises.stat(fileName); | ||||||
|             const isOutdated = Date.now() - mtime.getTime() > ONE_WEEK; |             const isOutdated = Date.now() - mtime.getTime() > THREE_DAYS; | ||||||
|             if (isOutdated) { |             if (isOutdated) { | ||||||
|                 await rm(dir.path, dirent); |                 await rm(dir.path, dirent); | ||||||
|             } |             } | ||||||
|  | |||||||
							
								
								
									
										6
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							| @ -87258,7 +87258,7 @@ async function cleanGit(packages) { | |||||||
|     } |     } | ||||||
|     catch { } |     catch { } | ||||||
| } | } | ||||||
| const ONE_WEEK = 7 * 24 * 3600 * 1000; | const THREE_DAYS = 3 * 24 * 3600 * 1000; | ||||||
| /** | /** | ||||||
|  * Removes all files or directories in `dirName` matching some criteria. |  * Removes all files or directories in `dirName` matching some criteria. | ||||||
|  * |  * | ||||||
| @ -87275,7 +87275,7 @@ async function rmExcept(dirName, keepPrefix, checkTimestamp = false) { | |||||||
|         if (checkTimestamp) { |         if (checkTimestamp) { | ||||||
|             const fileName = external_path_default().join(dir.path, dirent.name); |             const fileName = external_path_default().join(dir.path, dirent.name); | ||||||
|             const { mtime } = await external_fs_default().promises.stat(fileName); |             const { mtime } = await external_fs_default().promises.stat(fileName); | ||||||
|             const isOutdated = Date.now() - mtime.getTime() > ONE_WEEK; |             const isOutdated = Date.now() - mtime.getTime() > THREE_DAYS; | ||||||
|             if (isOutdated) { |             if (isOutdated) { | ||||||
|                 await rm(dir.path, dirent); |                 await rm(dir.path, dirent); | ||||||
|             } |             } | ||||||
| @ -87351,7 +87351,7 @@ async function run() { | |||||||
|             allPackages.push(...packages); |             allPackages.push(...packages); | ||||||
|             try { |             try { | ||||||
|                 core.info(`... Cleaning ${workspace.target} ...`); |                 core.info(`... Cleaning ${workspace.target} ...`); | ||||||
|                 await cleanTargetDir(workspace.target, packages); |                 await cleanTargetDir(workspace.target, packages, true); | ||||||
|             } |             } | ||||||
|             catch (e) { |             catch (e) { | ||||||
|                 core.debug(`${e.stack}`); |                 core.debug(`${e.stack}`); | ||||||
|  | |||||||
| @ -253,7 +253,7 @@ export async function cleanGit(packages: Packages) { | |||||||
|   } catch {} |   } catch {} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const ONE_WEEK = 7 * 24 * 3600 * 1000; | const THREE_DAYS = 3 * 24 * 3600 * 1000; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Removes all files or directories in `dirName` matching some criteria. |  * Removes all files or directories in `dirName` matching some criteria. | ||||||
| @ -271,7 +271,7 @@ async function rmExcept(dirName: string, keepPrefix: Set<string>, checkTimestamp | |||||||
|     if (checkTimestamp) { |     if (checkTimestamp) { | ||||||
|       const fileName = path.join(dir.path, dirent.name); |       const fileName = path.join(dir.path, dirent.name); | ||||||
|       const { mtime } = await fs.promises.stat(fileName); |       const { mtime } = await fs.promises.stat(fileName); | ||||||
|       const isOutdated = Date.now() - mtime.getTime() > ONE_WEEK; |       const isOutdated = Date.now() - mtime.getTime() > THREE_DAYS; | ||||||
| 
 | 
 | ||||||
|       if (isOutdated) { |       if (isOutdated) { | ||||||
|         await rm(dir.path, dirent); |         await rm(dir.path, dirent); | ||||||
|  | |||||||
| @ -47,7 +47,7 @@ async function run() { | |||||||
|       allPackages.push(...packages); |       allPackages.push(...packages); | ||||||
|       try { |       try { | ||||||
|         core.info(`... Cleaning ${workspace.target} ...`); |         core.info(`... Cleaning ${workspace.target} ...`); | ||||||
|         await cleanTargetDir(workspace.target, packages); |         await cleanTargetDir(workspace.target, packages, true); | ||||||
|       } catch (e) { |       } catch (e) { | ||||||
|         core.debug(`${(e as any).stack}`); |         core.debug(`${(e as any).stack}`); | ||||||
|       } |       } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user