Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

List what rustup leaves in its temporary folder on the Developer page

Țugui Dragoș215b13d84934
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
index 61826078..10e91f30 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
@@ -631,6 +631,7 @@ public enum DeveloperCaches {
// Only what rustup downloaded, which `rustup update` empties itself, never the toolchains it installed.
Definition(id: "rustup", name: "rustup", systemImage: "gearshape.2", appBundleIdentifiers: [], folders: [
Folder(".rustup/downloads", .downloads, source: "https://github.com/rust-lang/rustup/blob/b46db5ea94c1024c7cd2e7133a7f9b2ec1927478/src/cli/rustup_mode.rs#L1203-L1205"),
+ Folder(".rustup/tmp", .cache, source: "https://github.com/rust-lang/rustup/blob/b46db5ea94c1024c7cd2e7133a7f9b2ec1927478/src/dist/download.rs#L44-L45"),
]),
Definition(id: "cargo", name: "Cargo", systemImage: "gearshape.2", appBundleIdentifiers: [], folders: [
Folder(".cargo/registry/cache", .downloads, source: "https://github.com/rust-lang/cargo/blob/bb2126cffae48394a37db8728dc50a17bbfe54d4/doc/book/src/guide/cargo-home.md#L47-L48"),
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
index a1eee546..39da3ef2 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
@@ -460,11 +460,12 @@ struct DeveloperCachesTests {
// CocoaPods' spec repositories hold the ones a person added, which can carry unpushed work: only the copies of
// the public index are listed, the CDN's `trunk` and the Git clone CocoaPods names `master` or `cocoapods`,
// which is the tool's only when its origin is that index. nvm's, pyenv's, rbenv's and rustup's folders hold
- // every version they installed; only their download caches are caches.
+ // every version they installed; only their download caches are caches, and rustup's temporary folder, which
+ // `rustup update` empties.
let onlyTheseParts: [String: Set<String>] = [
".cocoapods/repos": [".cocoapods/repos/trunk", ".cocoapods/repos/master", ".cocoapods/repos/cocoapods"],
".nvm": [".nvm/.cache"], ".pyenv": [".pyenv/cache"], ".rbenv": [".rbenv/cache"],
- ".rustup": [".rustup/downloads"],
+ ".rustup": [".rustup/downloads", ".rustup/tmp"],
]
for definition in DeveloperCaches.definitions {
for path in definition.folders.map(\.path) {
@@ -1315,15 +1316,16 @@ struct DeveloperCachesTests {
#expect(locations.allSatisfy { $0.kind == .downloads && $0.isRecommended })
}
- @Test func offersWhatRustupDownloadedAndNeverItsToolchains() async throws {
+ @Test func offersWhatRustupDownloadedOrLeftInItsTemporaryFolderAndNeverItsToolchains() async throws {
let directory = try TemporaryDirectory()
try directory.file(".rustup/downloads/4b1c.partial", bytes: 400_000)
+ try directory.file(".rustup/tmp/7d2e_dir/lib/librustc_driver.dylib", bytes: 400_000)
try directory.file(".rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc", bytes: 400_000)
let rustup = DeveloperCaches.definitions.filter { $0.id == "rustup" }
let locations = await DeveloperCaches.scan(rustup, homeDirectory: directory.url).flatMap(\.locations)
- #expect(locations.map(\.url.lastPathComponent) == ["downloads"])
+ #expect(Set(locations.map(\.url.lastPathComponent)) == ["downloads", "tmp"])
}
@Test func offersCpansBuildFolderAndNeverItsPreferences() async throws {