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.

Keep a Solana program's key out of what a scan suggests

Țugui Dragoș09e83b0289a0
diff --git a/Packages/PeelCore/Sources/PeelCore/Support/FileSize.swift b/Packages/PeelCore/Sources/PeelCore/Support/FileSize.swift
index 23bdd0da..563f1481 100644
--- a/Packages/PeelCore/Sources/PeelCore/Support/FileSize.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Support/FileSize.swift
@@ -290,7 +290,8 @@ public enum FileSize {
/// (Cosmos), `voting-keystore.json` (Lighthouse), `all-accounts.keystore.json` (Prysm), `masterseed.json` (Clef),
/// `starknet_open_zeppelin_accounts.json` (sncast), `wallets.ldb` (Nano), `*.jmdat` (JoinMarket),
/// `zecwallet-light-wallet.backup.*` (Zecwallet Lite), `sui.keystore`, `sqlite_wallets` (Algorand),
- /// `encryption-identity.txt` (Zallet), and `.aptos`.
+ /// `encryption-identity.txt` (Zallet), `*-keypair.json` (a Solana program's key, which `cargo build-sbf` writes
+ /// in `target/deploy` and which gives the program its address), and `.aptos`.
static func isWallet(_ name: String) -> Bool {
let name = name.lowercased()
return walletNames.contains(name) || walletSuffixes.contains { name.hasSuffix($0) }
@@ -305,7 +306,9 @@ public enum FileSize {
"encryption-identity.txt", ".aptos",
]
- private static let walletSuffixes = ["wallet.dat", ".legacy.bak", ".wallet", ".keys", ".mmdbdoc_v1", ".jmdat"]
+ private static let walletSuffixes = [
+ "wallet.dat", ".legacy.bak", ".wallet", ".keys", ".mmdbdoc_v1", ".jmdat", "-keypair.json",
+ ]
private static let walletPrefixes = ["wallet.dat.", "zecwallet-light-wallet.backup."]
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileSizeTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileSizeTests.swift
index f95a09dd..335193f1 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/FileSizeTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileSizeTests.swift
@@ -485,6 +485,7 @@ struct FileSizeTests {
"wallet.dat.2026-10-05-12-30", "zecwallet-light-wallet.backup.1767225600.dat", "node_seed.dat",
"channel_seed.dat", "voting-keystore.json", "all-accounts.keystore.json", "masterseed.json", "wallets.ldb",
"WalletBackups", "starknet_open_zeppelin_accounts.json", "wallet.jmdat", "default_wallet_1767225600.legacy.bak",
+ "hello_world-keypair.json",
]
for name in wallets {
#expect(FileSize.isWallet(name), "\(name) was not read as a wallet")
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
index fc88ea86..b7003f05 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
@@ -401,7 +401,8 @@ struct ProjectArtifactsTests {
}
/// What may exist nowhere else is never selected: a repository, or a wallet. A repository inside a folder its
- /// tool tags as a cache is the tool's own clone, which it makes again, as Swift Package Manager does for `.build`.
+ /// tool tags as a cache is the tool's own clone, which it makes again, as Swift Package Manager does for `.build`;
+ /// a key is never made again, so Cargo's tag on `target` does not cover a Solana program's key inside it.
@Test func anArtifactHoldingARepositoryOrAWalletIsNotSelected() async throws {
let directory = try TemporaryDirectory()
let tag = Data("Signature: 8a477f597d28d172789f06886806bc55\n# a cache directory tag\n".utf8)
@@ -413,12 +414,15 @@ struct ProjectArtifactsTests {
try directory.file("Projects/old/Package.swift", bytes: 16)
try directory.file("Projects/old/.build/CACHEDIR.TAG", contents: Data("not a tag".utf8))
try directory.file("Projects/old/.build/checkouts/dep/.git/HEAD", bytes: 16)
+ try directory.file("Projects/program/Cargo.toml", bytes: 16)
+ try directory.file("Projects/program/target/CACHEDIR.TAG", contents: tag)
+ try directory.file("Projects/program/target/deploy/vault-keypair.json", bytes: 16)
try age(directory.url, days: 60)
let found = await ProjectArtifacts.scan(roots: [directory.url.appending(path: "Projects")]).artifacts
let reasons = found.map { "\($0.project.lastPathComponent): \($0.heldBack.map(\.rawValue) ?? "none")" }.sorted()
- #expect(reasons == ["old: holdsRepository", "site: holdsAWallet", "tool: none"])
+ #expect(reasons == ["old: holdsRepository", "program: holdsAWallet", "site: holdsAWallet", "tool: none"])
#expect(found.filter(\.isRecommended).map(\.project.lastPathComponent) == ["tool"])
}