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.

Offer no link to peel from a read-only disk, and say where Peel runs from

Țugui Dragoș0e2b1d8ad10d
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index eb065e86..e70b4d04 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -121608,6 +121608,112 @@
}
}
},
+ "Peel is running from a read-only disk, such as the disk image it came on. Move Peel to the Applications folder and open it from there." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel běží z disku jen pro čtení, například z obrazu disku, na kterém byl dodán. Přesuňte Peel do složky Aplikace a otevřete ho odtamtud."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel wird von einem schreibgeschützten Volume ausgeführt, etwa von der Image-Datei, mit der Peel geliefert wurde. Bewege Peel in den Ordner „Programme“ und öffne es von dort."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel se está ejecutando desde un disco de solo lectura, como la imagen de disco en la que venía. Mueve Peel a la carpeta Aplicaciones y ábrelo desde ahí."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel s’exécute depuis un disque en lecture seule, comme l’image disque sur laquelle il a été distribué. Déplacez Peel dans le dossier Applications et ouvrez-le depuis cet emplacement."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel è in esecuzione da un disco di sola lettura, come l’immagine disco da cui proviene. Sposta Peel nella cartella Applicazioni e aprilo da lì."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peelは、配布用のディスクイメージなど、読み出し専用のディスクから実行されています。Peelを“アプリケーション”フォルダに移動し、そこから開いてください。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel이 읽기 전용 디스크(예: Peel의 디스크 이미지)에서 실행되고 있습니다. Peel을 응용 프로그램 폴더로 옮긴 다음 그곳에서 여십시오."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel wordt uitgevoerd vanaf een alleen-lezenschijf, zoals de schijfkopie waarop het is geleverd. Verplaats Peel naar de map 'Apps' en open het daarvandaan."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel działa z dysku tylko do odczytu, na przykład z obrazu dysku, na którym został dostarczony. Przenieś Peel do folderu Aplikacje i otwórz go stamtąd."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Peel está sendo executado a partir de um disco somente leitura, como a imagem de disco em que ele veio. Mova o Peel para a pasta Aplicativos e abra-o de lá."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel rulează de pe un disc doar pentru citire, cum ar fi imaginea sa de disc. Mutați Peel în dosarul Aplicații și deschideți‑l de acolo."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel запущен с диска только для чтения, например с образа диска, в котором он поставлялся. Переместите Peel в папку «Программы» и откройте его оттуда."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel körs från en skrivskyddad skiva, till exempel den skivavbild som Peel levererades på. Flytta Peel till mappen Appar och öppna appen därifrån."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel, içinde geldiği disk görüntüsü gibi salt okunur bir diskten çalışıyor. Peel’i Uygulamalar klasörüne taşıyın ve oradan açın."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel працює з диска, доступного лише для читання, як-от з образу диска, у якому вона постачається. Перемістіть Peel у папку «Програми» й відкрийте звідти."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel正在从只读磁盘运行,例如它所在的磁盘映像。请将Peel移到“应用程序”文件夹,然后从那里打开它。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel正從唯讀磁碟執行,例如它原本所在的磁碟映像檔。請將Peel移到「應用程式」檔案夾,然後從那裡打開。"
+ }
+ }
+ }
+ },
"Peel is still moving something, putting something back, or running Homebrew. Try again once it’s done." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Home/Access.swift b/Packages/PeelCore/Sources/PeelCore/Home/Access.swift
index a4a74894..1cc233e2 100644
--- a/Packages/PeelCore/Sources/PeelCore/Home/Access.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Home/Access.swift
@@ -89,25 +89,31 @@ public enum CommandLineTool {
/// The temporary copy macOS runs an app from while it is still marked as downloaded (App Translocation).
/// Its path changes every time and it is gone when the app quits, so no link may point into it.
case temporaryCopy
+ /// A disk Peel can't write to, such as the disk image it came on, which is ejected sooner or later.
+ case readOnlyVolume
/// Anywhere else, such as Downloads, a disk image, or a build folder. An app there may still be moved.
case elsewhere
}
- public static func place(of bundle: URL = Bundle.main.bundleURL, home: URL = .homeDirectory) -> Place {
+ public static func place(
+ of bundle: URL = Bundle.main.bundleURL, home: URL = .homeDirectory,
+ isReadOnly: (URL) -> Bool = SelfRemoval.isOnAReadOnlyVolume
+ ) -> Place {
let path = PathPattern.comparablePath(of: bundle)
guard !path.contains("/AppTranslocation/") else { return .temporaryCopy }
let applications = ["/Applications", PathPattern.comparablePath(of: home) + "/Applications"]
- return applications.contains { PathComponents.isPath(path, inside: $0) } ? .applications : .elsewhere
+ guard !applications.contains(where: { PathComponents.isPath(path, inside: $0) }) else { return .applications }
+ return isReadOnly(bundle) ? .readOnlyVolume : .elsewhere
}
/// The shell command that links the tool, built from where Peel really is rather than a fixed path, or nil once the
/// link leads to this copy's tool, where something that may not be Peel's is in the link's place, and from a
- /// temporary copy, whose link would lead nowhere once Peel quits. `ln -f` deletes what is there, so only a link to
- /// another Peel's tool is replaced. A single quote in the path is closed, escaped, and reopened, so the shell reads
- /// the path as written.
+ /// temporary copy or a read-only disk, whose link would lead nowhere once Peel quits or the disk is ejected.
+ /// `ln -f` deletes what is there, so only a link to another Peel's tool is replaced. A single quote in the path is
+ /// closed, escaped, and reopened, so the shell reads the path as written.
public static func installCommand(embedded: URL, standing: Standing) -> String? {
let bundle = embedded.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
- guard place(of: bundle) != .temporaryCopy else { return nil }
+ guard ![.temporaryCopy, .readOnlyVolume].contains(place(of: bundle)) else { return nil }
let path = embedded.path(percentEncoded: false).replacingOccurrences(of: "'", with: "'\\''")
let link = switch standing {
case .missing: "ln -s"
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomeTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomeTests.swift
index b31b68c3..b3e17639 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/HomeTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomeTests.swift
@@ -320,6 +320,8 @@ struct AppManagementTests {
#expect(place("/Users/me/Downloads/Peel.app") == .elsewhere)
#expect(place("/Volumes/Peel 1.0/Peel.app") == .elsewhere)
#expect(place("/private/var/folders/x2/abc/d/AppTranslocation/41B9A/d/Peel.app") == .temporaryCopy)
+ let onItsDiskImage = URL(filePath: "/Volumes/Peel/Peel.app", directoryHint: .isDirectory)
+ #expect(CommandLineTool.place(of: onItsDiskImage, home: home, isReadOnly: { _ in true }) == .readOnlyVolume)
let command = CommandLineTool.installCommand(embedded: URL(filePath: "/Users/me/Sam's Apps/Peel.app/Contents/Helpers/peel"), standing: .missing)
#expect(command?.hasSuffix("sudo ln -s '/Users/me/Sam'\\''s Apps/Peel.app/Contents/Helpers/peel' /usr/local/bin/peel") == true)
diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swift
index 46fcdfb9..156f633c 100644
--- a/Peel/Views/Settings/SettingsView.swift
+++ b/Peel/Views/Settings/SettingsView.swift
@@ -372,12 +372,18 @@ private struct GeneralSettingsView: View {
Text("Peel is running from a copy macOS made because it is still marked as downloaded. Move Peel to the Applications folder and open it from there.")
.font(.caption)
.foregroundStyle(.secondary)
- case .elsewhere:
- Text("The link points at Peel where it is now, \(Text(verbatim: Bundle.main.bundleURL.abbreviatedPath)), so it breaks if Peel moves. Apps live in the Applications folder.")
+ case .readOnlyVolume:
+ Text("Peel is running from a read-only disk, such as the disk image it came on. Move Peel to the Applications folder and open it from there.")
.font(.caption)
.foregroundStyle(.secondary)
+ case .elsewhere:
+ if commandLine == .installed || installCommand != nil {
+ Text("The link points at Peel where it is now, \(Text(verbatim: Bundle.main.bundleURL.abbreviatedPath)), so it breaks if Peel moves. Apps live in the Applications folder.")
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ }
}
- if Self.place != .temporaryCopy, commandLine != .installed {
+ if [.applications, .elsewhere].contains(Self.place), commandLine != .installed {
if let installCommand {
Text(verbatim: installCommand)
.font(.caption.monospaced())