mirror of
				https://github.com/Swatinem/rust-cache.git
				synced 2025-10-31 19:33:48 +00:00 
			
		
		
		
	improve registry cleanpu
This commit is contained in:
		
							parent
							
								
									7b8626742a
								
							
						
					
					
						commit
						0497f9301f
					
				
							
								
								
									
										2
									
								
								TODO.md
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								TODO.md
									
									
									
									
									
								
							| @ -2,5 +2,3 @@ | ||||
| - better .cargo/bin handling: | ||||
|   - get a list of all the files on "pre"/"restore" | ||||
|   - move the files out of the way on "post"/"save" and move them back afterwards | ||||
| - better .cargo/registry handling: | ||||
|   - rather implement better cleaning logic for the registry | ||||
|  | ||||
							
								
								
									
										10
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							| @ -61910,6 +61910,7 @@ async function cleanBin() { | ||||
| } | ||||
| async function cleanRegistry(packages) { | ||||
|     // `.cargo/registry/src`
 | ||||
|     // we can remove this completely, as cargo will recreate this from `cache`
 | ||||
|     const srcDir = path.join(CARGO_HOME, "registry", "src"); | ||||
|     await io.rmRF(srcDir); | ||||
|     // `.cargo/registry/index`
 | ||||
| @ -61919,9 +61920,11 @@ async function cleanRegistry(packages) { | ||||
|             // eg `.cargo/registry/index/github.com-1ecc6299db9ec823`
 | ||||
|             // or `.cargo/registry/index/index.crates.io-e139d0d48fed7772`
 | ||||
|             const dir = await fs.promises.opendir(path.join(indexDir.path, dirent.name)); | ||||
|             // TODO: check for `.git` etc, for now we just always remove the `.cache`
 | ||||
|             // and leave other stuff untouched.
 | ||||
|             await io.rmRF(path.join(dir.path, ".cache")); | ||||
|             // for a git registry, we can remove `.cache`, as cargo will recreate it from git
 | ||||
|             if (await exists(path.join(dir.path, ".git"))) { | ||||
|                 await io.rmRF(path.join(dir.path, ".cache")); | ||||
|             } | ||||
|             // TODO: else, clean `.cache` based on the `packages`
 | ||||
|         } | ||||
|     } | ||||
|     const pkgSet = new Set(packages.map((p) => `${p.name}-${p.version}.crate`)); | ||||
| @ -61933,6 +61936,7 @@ async function cleanRegistry(packages) { | ||||
|             // or `.cargo/registry/cache/index.crates.io-e139d0d48fed7772`
 | ||||
|             const dir = await fs.promises.opendir(path.join(cacheDir.path, dirent.name)); | ||||
|             for await (const dirent of dir) { | ||||
|                 // here we check that the downloaded `.crate` matches one from our dependencies
 | ||||
|                 if (dirent.isFile() && !pkgSet.has(dirent.name)) { | ||||
|                     await rm(dir.path, dirent); | ||||
|                 } | ||||
|  | ||||
							
								
								
									
										10
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							| @ -61910,6 +61910,7 @@ async function cleanBin() { | ||||
| } | ||||
| async function cleanRegistry(packages) { | ||||
|     // `.cargo/registry/src`
 | ||||
|     // we can remove this completely, as cargo will recreate this from `cache`
 | ||||
|     const srcDir = external_path_default().join(CARGO_HOME, "registry", "src"); | ||||
|     await io.rmRF(srcDir); | ||||
|     // `.cargo/registry/index`
 | ||||
| @ -61919,9 +61920,11 @@ async function cleanRegistry(packages) { | ||||
|             // eg `.cargo/registry/index/github.com-1ecc6299db9ec823`
 | ||||
|             // or `.cargo/registry/index/index.crates.io-e139d0d48fed7772`
 | ||||
|             const dir = await external_fs_default().promises.opendir(external_path_default().join(indexDir.path, dirent.name)); | ||||
|             // TODO: check for `.git` etc, for now we just always remove the `.cache`
 | ||||
|             // and leave other stuff untouched.
 | ||||
|             await io.rmRF(external_path_default().join(dir.path, ".cache")); | ||||
|             // for a git registry, we can remove `.cache`, as cargo will recreate it from git
 | ||||
|             if (await exists(external_path_default().join(dir.path, ".git"))) { | ||||
|                 await io.rmRF(external_path_default().join(dir.path, ".cache")); | ||||
|             } | ||||
|             // TODO: else, clean `.cache` based on the `packages`
 | ||||
|         } | ||||
|     } | ||||
|     const pkgSet = new Set(packages.map((p) => `${p.name}-${p.version}.crate`)); | ||||
| @ -61933,6 +61936,7 @@ async function cleanRegistry(packages) { | ||||
|             // or `.cargo/registry/cache/index.crates.io-e139d0d48fed7772`
 | ||||
|             const dir = await external_fs_default().promises.opendir(external_path_default().join(cacheDir.path, dirent.name)); | ||||
|             for await (const dirent of dir) { | ||||
|                 // here we check that the downloaded `.crate` matches one from our dependencies
 | ||||
|                 if (dirent.isFile() && !pkgSet.has(dirent.name)) { | ||||
|                     await rm(dir.path, dirent); | ||||
|                 } | ||||
|  | ||||
| @ -93,6 +93,7 @@ export async function cleanBin() { | ||||
| 
 | ||||
| export async function cleanRegistry(packages: Packages) { | ||||
|   // `.cargo/registry/src`
 | ||||
|   // we can remove this completely, as cargo will recreate this from `cache`
 | ||||
|   const srcDir = path.join(CARGO_HOME, "registry", "src"); | ||||
|   await io.rmRF(srcDir); | ||||
| 
 | ||||
| @ -104,9 +105,11 @@ export async function cleanRegistry(packages: Packages) { | ||||
|       // or `.cargo/registry/index/index.crates.io-e139d0d48fed7772`
 | ||||
|       const dir = await fs.promises.opendir(path.join(indexDir.path, dirent.name)); | ||||
| 
 | ||||
|       // TODO: check for `.git` etc, for now we just always remove the `.cache`
 | ||||
|       // and leave other stuff untouched.
 | ||||
|       await io.rmRF(path.join(dir.path, ".cache")); | ||||
|       // for a git registry, we can remove `.cache`, as cargo will recreate it from git
 | ||||
|       if (await exists(path.join(dir.path, ".git"))) { | ||||
|         await io.rmRF(path.join(dir.path, ".cache")); | ||||
|       } | ||||
|       // TODO: else, clean `.cache` based on the `packages`
 | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| @ -120,6 +123,7 @@ export async function cleanRegistry(packages: Packages) { | ||||
|       // or `.cargo/registry/cache/index.crates.io-e139d0d48fed7772`
 | ||||
|       const dir = await fs.promises.opendir(path.join(cacheDir.path, dirent.name)); | ||||
|       for await (const dirent of dir) { | ||||
|         // here we check that the downloaded `.crate` matches one from our dependencies
 | ||||
|         if (dirent.isFile() && !pkgSet.has(dirent.name)) { | ||||
|           await rm(dir.path, dirent); | ||||
|         } | ||||
|  | ||||
| @ -2,6 +2,7 @@ fn main() { | ||||
|     println!("Hello, world!"); | ||||
| } | ||||
| 
 | ||||
| #[cfg(test)] | ||||
| fn some_fn(input: bool) -> usize { | ||||
|     if input { | ||||
|         2 + 4 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user