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 Cabal's downloads and script builds in its older folder

Țugui Dragoș681ba60e6b1f
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
index 79292362..eb52967d 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
@@ -740,6 +740,10 @@ public enum DeveloperCaches {
]),
Definition(id: "cabal", name: "Cabal", systemImage: "shippingbox", appBundleIdentifiers: [], folders: [
Folder(".cache/cabal", .downloads, source: "https://github.com/haskell/cabal/blob/cdb488e5ef41005cb1fa9a534708a459a6e98b2e/doc/config.rst#L112-L115"),
+ // The same folders while Cabal still keeps everything in `~/.cabal`, beside its settings and what it
+ // installed.
+ Folder(".cabal/packages", .downloads, source: "https://github.com/haskell/cabal/blob/cdb488e5ef41005cb1fa9a534708a459a6e98b2e/cabal-install/src/Distribution/Client/Config.hs#L771-L823"),
+ Folder(".cabal/script-builds", .buildData, source: "https://github.com/haskell/cabal/blob/cdb488e5ef41005cb1fa9a534708a459a6e98b2e/cabal-install/src/Distribution/Client/Config.hs#L771-L823"),
]),
Definition(id: "stack", name: "Haskell Stack", systemImage: "shippingbox", appBundleIdentifiers: [], folders: [
Folder(".stack/pantry/hackage", .downloads, source: "https://github.com/commercialhaskell/stack/blob/d5effcd3f32e1dc3e6fc352c65938310f3acd675/doc/topics/stack_root.md#L228-L232"),
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
index 863b6089..699a38f8 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
@@ -436,7 +436,7 @@ struct DeveloperCachesTests {
"Library/Application Support/nomic.ai/GPT4All", "Library/Application Support/Adobe/Common",
// Coursier keeps the JVMs `cs java` installs beside its cache; a legacy `~/.ccache` holds `ccache.conf`;
// `~/.clojure` holds the person's own `deps.edn`.
- "Library/Caches/Coursier", ".ccache", ".clojure",
+ "Library/Caches/Coursier", ".ccache", ".clojure", ".cabal",
// Corepack keeps the package manager versions a person chose in `lastKnownGood.json` beside its downloads.
".cache/node/corepack",
// Hex and Gleam keep a Hex account's key beside their packages; pub, RubyGems, rebar3, Stack, and opam
@@ -1288,6 +1288,21 @@ struct DeveloperCachesTests {
#expect(locations.allSatisfy { $0.kind == .downloads && $0.isRecommended })
}
+ @Test func offersCabalsDownloadsInItsOldFolderAndNeverWhatItInstalled() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file(".cabal/packages/hackage.haskell.org/text/2.1.2/text-2.1.2.tar.gz", bytes: 400_000)
+ try directory.file(".cabal/script-builds/9f2c/cache/plan.json", bytes: 400_000)
+ try directory.file(".cabal/config", bytes: 64)
+ try directory.file(".cabal/store/ghc-9.10.1/text-2.1.2-a1b2/lib/Data/Text.hi", bytes: 400_000)
+ try directory.file(".cabal/bin/pandoc", bytes: 400_000)
+ let cabal = DeveloperCaches.definitions.filter { $0.id == "cabal" }
+
+ let locations = await DeveloperCaches.scan(cabal, homeDirectory: directory.url).flatMap(\.locations)
+
+ #expect(Set(locations.map(\.url.lastPathComponent)) == ["packages", "script-builds"])
+ #expect(locations.allSatisfy(\.isRecommended) == true)
+ }
+
@Test func offersWhatRustupDownloadedAndNeverItsToolchains() async throws {
let directory = try TemporaryDirectory()
try directory.file(".rustup/downloads/4b1c.partial", bytes: 400_000)