Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
Launcher: move the shell cache folder from Settings (#427)
v0lumehi84950ebfc71e
diff --git a/frontend/ARCHITECTURE.md b/frontend/ARCHITECTURE.mdindex 7ee855a2..3b37180a 100644--- a/frontend/ARCHITECTURE.md+++ b/frontend/ARCHITECTURE.md@@ -27,7 +27,7 @@ Step 1 of #387 made the targets and moved the files that already fit. Step 2 mov- `NXModel` holds `DeviceStore` (step 7, devices): the paired devices and their refresh (`devicectl list devices`), the signing teams, whether the listing ran (`checked`), the chosen install device and team (saved in the defaults), and the copy flow of the shared app: the question before the game data goes over (`shellCopy`, answered with `answerCopy`) and the wait for a cable (`shellWaiting`, `cancelWait`). The install runs on a background queue, so `askCopy`, `setWaiting` and `waitCancelled` are the blocking bridge it calls. `xcrun` is an injected value of the store (and of `LauncherStores.init`), no longer a loose property that tests assign. `LauncherStores` creates the store with its runner. The listings are closures with the real ones as default (`listDevices`, `readTeams`), so a test gives the store devices and teams. `LauncherStores.init(xcrun:volumesRoot:)` takes the two values that were loose hooks. `volumesRoot` (where external drives are mounted) is read by the failure classifier, not by a device tool, so it is an injected `let` of the build store. The views that show the install target (the Builds page) and the copy card observe the store. `NXCore` got what the store needs: `ShellCopyPlan`, `ShellCopyDecision` and `ShellConnection` (`ShellInstall.Connection` is an alias), `DeviceControl` (devicectl for the save transfer) and `LockedFlag`. `ProcessLaunch` got a `timeout` and an `input`, `ProcessResult` got `timedOut`, and `ProcessRunner` got one primitive, `streamLines` (merged output as whole lines, a callback when the process has started, an optional process group), with fakes and tests. `DeviceTools`, `AppSignature`, `DeviceControl` and `ShellInstaller` start their tools through a runner now. `NXModelTests` tests the store without SwiftUI, and `NXCoreTests` tests the tools against a fake runner.- `NXModel` holds `BuildStore` (step 7, build, the last store): the build inputs (the four rows `Slot`, the game folder, the output folder), the target, the stage list and whether a build runs, the handling of the script's JSON events (`ingest`), the run (the script's arguments and environment, stopping, the archive step), the install hand-off (`installShell`, the retry of the game data, the reinstall, the re-sign, the IPA, `openOnDevice`), the failure the card shows (`noteFailure`, `noteInstallFailure`), "Build anyway" and the fix buttons, the stale frameworks question and the files a drop adds. It decides whether a build may start (`canBuild`, and the checks at the top of `startBuild`). It is a class with six `BuildStore+` files, because no file may pass 800 lines. It gets what it needs through narrow protocols: `RepoLocation`, `DependencyInstalling` (`DependencyStatus` plus the install the fix buttons run), `EngineSyncing` (the sync a stale `engine/` needs) and `InstallTarget` (the device, the team, the teams the Mac knows and the copy flow). `DependencyStore`, `EngineSyncStore` and `DeviceStore` conform. AppKit reaches it as closures: the open, folder and save panels (`choosePaths`, `chooseFolder`, `chooseSaveLocation`), the notice (`showNotice`), the Finder (`revealFolder`, `openApp`) and `targetChanged`, which `LauncherStores` answers with a new dependency check when a Mac-only setup changes target. `NXCore` got what it needs: `ShellInstall`, `ShellLibrary`, `ShellInstaller` and `BannerCache` (the install of the shared app), `BuildFailureClassifier`, `VolumePath`, and `RomFSArchive` and `BuildCommands` (the archive stamp, the add-on content copy, the reinstall and IPA commands, the tools' PATH). `ShellCLI` (the terminal install) stays in the app target. `NXModelTests` tests the store with fake stores and a fake runner, without SwiftUI. The build's process start and its output callbacks are tested in the app target through the real build script stand-ins in `ShellInstallTests`.- `NXModel` also holds `BuildLog`: the log text, its tail trimming and the line buffer. `BuildStore` holds it in a `let` and does not publish it, and only `BuildLogView` (in `NXLauncher`) observes it. A log line redraws the log and no game card. `LauncherPerformanceTests` writes 1000 lines during a build and allows 0 cards.-- `NXLauncher` holds the views and styles that need only `NXModel`, `NXCore`, SwiftUI and AppKit (step 8). The styles: `LauncherPalette`, `Typography`, `LauncherStyles`, `LauncherDropdown`, `PadFocus` and `EmbeddedFonts`. The pieces of a card (`LauncherCard.swift`: `CardGroup`, `CardRow`, `CardDivider`, `CardDisclosure`, `CardPageHeading` and `LauncherPageScroll`, the scrolling column of a page). One view per card of the Builds page: `SetupHintCard`, `TargetCard`, `InstallCard`, `LogCard` (with `BuildLogView`), `ActionCard`, `OutcomeCard` and `ProgressCard`, and the cards that belong beside them, `ShellCopyCard`, `BuildFailureCard` and `EngineSyncBanner`. One view per card of the Settings page: `ControlsCard`, `ToolsCard` and `AppCard`. Also `UpdateSheet`, the `GameFilesDrop` target, `RowScroller` and `DockProgress`. Each card declares the stores it shows as `@ObservedObject` parameters and observes nothing else. A value from another store comes as a value (`buildRunning`, `shellCachePath`) or a closure, never through another store. What only the app can give a card comes as a binding or a view builder: the switches kept in the app's defaults (`AppCard`, `ControlsCard`) and the diagnostics button (`ToolsCard`). `AppCard.languageCodes` lists the languages of the picker: the files in `frontend/l10n`, each shown by its own name.+- `NXLauncher` holds the views and styles that need only `NXModel`, `NXCore`, SwiftUI and AppKit (step 8). The styles: `LauncherPalette`, `Typography`, `LauncherStyles`, `LauncherDropdown`, `PadFocus` and `EmbeddedFonts`. The pieces of a card (`LauncherCard.swift`: `CardGroup`, `CardRow`, `CardDivider`, `CardDisclosure`, `CardPageHeading` and `LauncherPageScroll`, the scrolling column of a page). One view per card of the Builds page: `SetupHintCard`, `TargetCard`, `InstallCard`, `LogCard` (with `BuildLogView`), `ActionCard`, `OutcomeCard` and `ProgressCard`, and the cards that belong beside them, `ShellCopyCard`, `BuildFailureCard` and `EngineSyncBanner`. One view per card of the Settings page: `ControlsCard`, `ToolsCard` and `AppCard`. Also `UpdateSheet`, the `GameFilesDrop` target, `RowScroller` and `DockProgress`. Each card declares the stores it shows as `@ObservedObject` parameters and observes nothing else. A value from another store comes as a value (`buildRunning`) or a closure, never through another store. What only the app can give a card comes as a binding or a view builder: the switches kept in the app's defaults (`AppCard`, `ControlsCard`), the diagnostics button and the cache row (`ToolsCard`). The cache row is `ShellCacheRow`, a view of its own that observes the build store, because Move cache folder runs on the build's `running` flag (#427). `AppCard.languageCodes` lists the languages of the picker: the files in `frontend/l10n`, each shown by its own name.- `NX2Apple` holds everything else: the wiring (`LauncherStores`), the root view `LauncherView` and the views that need an app type, the panels and the drivers. `CardPages` is the scrolling column both settings and builds pages share (it keeps the scroll position, the open log and the open extra rows when someone goes from one page to the other) and `BuildPage` and `SettingsPage` only list the cards of their page. `FilesCard` stays here because it runs `KeyCheck`, which needs CommonCrypto. `LibraryCard` observes `GameLibrary`. The other views stay because they read an app type: `LauncherView`, `Library`, `ManageMenu` and `LaunchOptionsView` read `GameLibrary`, `LibraryGame` or `LauncherGamepad`, `CheatsView` reads `CheatFiles`, `FrameTimesView` reads `FrameTimes`, the console views read `ConsoleState` and the glyphs read `LauncherGamepad`, `OnboardingView` reads `OnboardingState` and its drivers. They move when those types do.## Access leveldiff --git a/frontend/Sources/NX2Apple/SettingsPage.swift b/frontend/Sources/NX2Apple/SettingsPage.swiftindex 01c94bf1..88aa7add 100644--- a/frontend/Sources/NX2Apple/SettingsPage.swift+++ b/frontend/Sources/NX2Apple/SettingsPage.swift@@ -32,7 +32,7 @@ struct SettingsPage: View {ControlsCard(controlChanges: controlChanges, padMerge: padMerge, consolePrompt: $consolePromptOn,startInConsole: $startInConsole, onOpenControls: onOpenControls, onOpenControllers: onOpenControllers)ToolsCard(repo: repo, engine: engine, dependencies: dependencies, buildRunning: build.running,- shellCachePath: build.shellCachePath, revealFolder: { build.revealFolder($0) }) {+ shellCache: { ShellCacheRow(build: build) }) {DiagnosticsButton(report: diagnostics, game: library.selected)}AppCard(updates: updates, buildRunning: build.running, notify: $notifyBuilds, notifyAvailable: BuildNotice.hasBundleID,diff --git a/frontend/Sources/NXCore/ShellInstall.swift b/frontend/Sources/NXCore/ShellInstall.swiftindex 01e4a95b..76dafd77 100644--- a/frontend/Sources/NXCore/ShellInstall.swift+++ b/frontend/Sources/NXCore/ShellInstall.swift@@ -83,7 +83,9 @@ package struct ShellLibrary: Codable, Equatable {/// root at a volume root is repaired (#492).package static func resolveRoot(defaults: UserDefaults = .standard, parent: String, home: String = NSHomeDirectory()) -> String {if let saved = defaults.string(forKey: "shellRoot"), rootIsUsable(saved) {- return ShellRootMigration.isLegacy(saved, home: home) ? settle(legacy: saved, defaults: defaults, home: home) : saved+ // A cache folder the player moved there (Move cache folder, ShellRootMove) is named like an old one but stays+ let legacy = ShellRootMigration.isLegacy(saved, home: home) && !defaults.bool(forKey: ShellRootMove.pickedKey)+ return legacy ? settle(legacy: saved, defaults: defaults, home: home) : saved}let legacy = parentFolder(parent, home: home) + "/" + ShellRootMigration.legacyNameif FileManager.default.fileExists(atPath: legacy) { return settle(legacy: legacy, defaults: defaults, home: home) }diff --git a/frontend/Sources/NXCore/ShellRootMigration.swift b/frontend/Sources/NXCore/ShellRootMigration.swiftindex 5fbae753..37aff45a 100644--- a/frontend/Sources/NXCore/ShellRootMigration.swift+++ b/frontend/Sources/NXCore/ShellRootMigration.swift@@ -23,7 +23,8 @@ package enum ShellRootMigration {/// At launch: a saved root of the old kind moves now, so every screen shows the same folder from the start.package static func migrateSavedRoot(defaults: UserDefaults = .standard, home: String = NSHomeDirectory()) {- guard let saved = defaults.string(forKey: "shellRoot"), isLegacy(saved, home: home) else { return }+ guard let saved = defaults.string(forKey: "shellRoot"), isLegacy(saved, home: home),+ !defaults.bool(forKey: ShellRootMove.pickedKey) else { return }_ = ShellLibrary.resolveRoot(defaults: defaults, parent: "", home: home)}diff --git a/frontend/Sources/NXCore/ShellRootMove.swift b/frontend/Sources/NXCore/ShellRootMove.swiftnew file mode 100644index 00000000..e9106dd6--- /dev/null+++ b/frontend/Sources/NXCore/ShellRootMove.swift@@ -0,0 +1,290 @@+import Foundation++// LNPANDY/NX2Apple#427, part 2: the player moves the shell cache (frameworks, shell.json, the banner cache, the shell project and+// its derived data) to another folder, for example an external drive, and back to the default place. The cache goes into a folder+// `NX2Apple-shell` inside the folder the player picked, so the launcher never owns, fills or removes a folder the player chose as a+// whole. The rules of the migration hold here too: a plain folder (no link), a readable shell.json, a free destination.+//+// On the same volume the move is a rename. On another volume the files are copied into a hidden folder beside the destination,+// every file is compared with its original, shell.json is rewritten in the copy, and only then the copy takes the destination's+// name and the old files are removed. A stop or an error before that point removes the partial copy and leaves the old folder+// as it was, so it stays valid and keeps being used. Nothing of the old folder is removed before the copy is verified.++package enum ShellRootMove {+ /// Set in the defaults when the saved root is one the player chose, so the migration at launch never moves it back.+ package static let pickedKey = "shellRootPicked"++ /// The cache folder inside the folder the player picked.+ package static func destination(inside folder: String) -> String {+ (folder as NSString).standardizingPath + "/" + ShellRootMigration.legacyName+ }++ /// Why the move cannot start.+ package enum Problem: Equatable {+ /// The cache is already there.+ case same+ /// The destination lies inside the cache.+ case insideCache+ /// The cache is a link, a file or an alias, not the plain folder the launcher made.+ case notPlain+ /// The cache folder holds files and no shell.json, so it is not a cache the launcher knows.+ case unknownContent+ /// shell.json is there but cannot be read.+ case unreadableLedger+ /// Something is already at the destination.+ case destinationTaken+ case readOnly+ case noSpace(needed: Int64, free: Int64)+ }++ /// What the confirmation shows, and what `run` does.+ package struct Plan: Equatable {+ package var source: String+ package var destination: String+ /// The size of the cache's files, 0 when there is no cache yet.+ package var bytes: Int64+ /// Free space on the destination's volume, nil when it cannot be read.+ package var free: Int64?+ /// The destination is on the cache's volume: the move is a rename.+ package var sameVolume: Bool+ /// There is a cache to move. Without one only the saved place changes.+ package var sourceExists: Bool+ package var problem: Problem?++ package init(source: String, destination: String, bytes: Int64, free: Int64?, sameVolume: Bool, sourceExists: Bool, problem: Problem?) {+ self.source = source; self.destination = destination; self.bytes = bytes; self.free = free+ self.sameVolume = sameVolume; self.sourceExists = sourceExists; self.problem = problem+ }+ }++ package static func plan(from source: String, to destination: String, fm: FileManager = .default) -> Plan {+ let source = (source as NSString).standardizingPath, destination = (destination as NSString).standardizingPath+ let volume = DriveCopy.volume(at: destination, fm: fm)+ var plan = Plan(source: source, destination: destination, bytes: 0, free: volume?.freeBytes,+ sameVolume: sameVolume(source, destination, fm: fm), sourceExists: false, problem: nil)+ if source == destination { plan.problem = .same; return plan }+ if destination.hasPrefix(source + "/") { plan.problem = .insideCache; return plan }+ let isLink = (try? fm.destinationOfSymbolicLink(atPath: source)) != nil+ plan.sourceExists = isLink || fm.fileExists(atPath: source)+ if plan.sourceExists {+ guard !isLink, ((try? fm.attributesOfItem(atPath: source))?[.type] as? FileAttributeType) == .typeDirectory else {+ plan.problem = .notPlain; return plan+ }+ guard let entries = try? fm.contentsOfDirectory(atPath: source) else { plan.problem = .notPlain; return plan }+ if entries.contains("shell.json") {+ guard let data = fm.contents(atPath: ShellLibrary.stateFile(root: source)),+ (try? JSONSerialization.jsonObject(with: data)) is [String: Any] else { plan.problem = .unreadableLedger; return plan }+ } else if !entries.filter({ $0 != ".DS_Store" }).isEmpty {+ plan.problem = .unknownContent; return plan+ }+ plan.bytes = treeSize(source, fm: fm)+ }+ if !isFree(destination, fm: fm) { plan.problem = .destinationTaken; return plan }+ if volume?.readOnly == true { plan.problem = .readOnly; return plan }+ if plan.sourceExists, !plan.sameVolume, let free = plan.free, plan.bytes > free {+ plan.problem = .noSpace(needed: plan.bytes, free: free)+ }+ return plan+ }++ package enum Phase: Equatable { case copying, checking }++ /// Why a move failed. The old folder stays and keeps being used in every case.+ package enum Failure: Equatable {+ /// A file system call failed: the system's own text.+ case io(String)+ /// A file of the copy is not the same as its original: its path inside the cache.+ case mismatch(String)+ /// shell.json could not be rewritten for the new place.+ case ledger+ }++ package enum Outcome: Equatable {+ case moved+ /// The cache is in its new place, but these files of the old folder could not be removed.+ case movedOldStays([String])+ /// The player stopped it. The old folder is as it was.+ case stopped+ case failed(Failure)+ }++ /// Moves the cache as the plan says. `progress` gets the phase and bytes done of the total, `stop` is asked between chunks.+ /// `afterCopy` runs on the copy before it is checked (tests use it to damage the copy). The caller saves the new root.+ package static func run(_ plan: Plan, fm: FileManager = .default, chunk: Int = 8 << 20,+ progress: (Phase, Int64, Int64) -> Void = { _, _, _ in }, stop: () -> Bool = { false },+ afterCopy: (String) -> Void = { _ in }) -> Outcome {+ guard plan.problem == nil else { return .failed(.io("the move cannot start")) }+ let source = plan.source, destination = plan.destination+ let parent = (destination as NSString).deletingLastPathComponent+ do { try fm.createDirectory(atPath: parent, withIntermediateDirectories: true) } catch { return .failed(.io(error.localizedDescription)) }+ guard plan.sourceExists else { return .moved }+ guard isFree(destination, fm: fm) else { return .failed(.io("the new place is taken")) }++ if plan.sameVolume {+ if stop() { return .stopped }+ do {+ try removeEmptyFolder(destination, fm: fm)+ try fm.moveItem(atPath: source, toPath: destination)+ } catch { return .failed(.io(error.localizedDescription)) }+ guard ShellRootMigration.rewritePaths(root: destination, from: source, to: destination, fm: fm) else {+ // shell.json still names the old place: put the folder back rather than leave a split state+ try? fm.moveItem(atPath: destination, toPath: source)+ return .failed(.ledger)+ }+ progress(.copying, plan.bytes, plan.bytes)+ return .moved+ }++ // Another volume: a hidden copy beside the destination, which is ours alone and may be removed on any failure+ let staging = parent + "/.\(ShellRootMigration.legacyName)-moving-\(UUID().uuidString)"+ func abandon(_ outcome: Outcome) -> Outcome { try? fm.removeItem(atPath: staging); return outcome }+ let entries: [String]+ do {+ entries = try fm.contentsOfDirectory(atPath: source)+ try fm.createDirectory(atPath: staging, withIntermediateDirectories: false)+ } catch { return abandon(.failed(.io(error.localizedDescription))) }+ var done: Int64 = 0+ do {+ for name in entries.sorted() {+ guard try copyItem(source + "/" + name, to: staging + "/" + name, fm: fm, chunk: chunk, done: &done,+ progress: { progress(.copying, $0, plan.bytes) }, stop: stop) else { return abandon(.stopped) }+ }+ } catch { return abandon(.failed(.io(error.localizedDescription))) }+ afterCopy(staging)+ var checked: Int64 = 0+ for name in entries.sorted() {+ switch compare(source + "/" + name, staging + "/" + name, relative: name, fm: fm, chunk: chunk, done: &checked,+ progress: { progress(.checking, $0, plan.bytes) }, stop: stop) {+ case .same: continue+ case .stopped: return abandon(.stopped)+ case .different(let path): return abandon(.failed(.mismatch(path)))+ }+ }+ guard ShellRootMigration.rewritePaths(root: staging, from: source, to: destination, fm: fm) else { return abandon(.failed(.ledger)) }+ do {+ try removeEmptyFolder(destination, fm: fm)+ try fm.moveItem(atPath: staging, toPath: destination)+ } catch { return abandon(.failed(.io(error.localizedDescription))) }++ // The copy is checked and in place. Only now the old files go: the entries the copy holds, then the folder if it is empty.+ var left: [String] = []+ for name in entries where name != ".DS_Store" {+ do { try fm.removeItem(atPath: source + "/" + name) } catch { left.append(source + "/" + name) }+ }+ if left.isEmpty { try? removeEmptyFolder(source, fm: fm) }+ return left.isEmpty ? .moved : .movedOldStays(left)+ }++ // MARK: Pieces++ /// Nothing is at `path`, or only an empty folder (a `.DS_Store` aside).+ static func isFree(_ path: String, fm: FileManager) -> Bool {+ if (try? fm.destinationOfSymbolicLink(atPath: path)) != nil { return false }+ guard fm.fileExists(atPath: path) else { return true }+ guard ((try? fm.attributesOfItem(atPath: path))?[.type] as? FileAttributeType) == .typeDirectory,+ let entries = try? fm.contentsOfDirectory(atPath: path) else { return false }+ return entries.allSatisfy { $0 == ".DS_Store" }+ }++ private static func removeEmptyFolder(_ path: String, fm: FileManager) throws {+ guard fm.fileExists(atPath: path), isFree(path, fm: fm) else { return }+ try fm.removeItem(atPath: path)+ }++ /// The bytes of the regular files under `path`, links not followed.+ static func treeSize(_ path: String, fm: FileManager) -> Int64 {+ guard let walker = fm.enumerator(at: URL(fileURLWithPath: path), includingPropertiesForKeys: [.fileSizeKey, .isRegularFileKey]) else { return 0 }+ var total: Int64 = 0+ for case let url as URL in walker {+ guard let values = try? url.resourceValues(forKeys: [.fileSizeKey, .isRegularFileKey]), values.isRegularFile == true else { continue }+ total += Int64(values.fileSize ?? 0)+ }+ return total+ }++ /// The volume of `a` and of the nearest folder that exists above `b`.+ static func sameVolume(_ a: String, _ b: String, fm: FileManager) -> Bool {+ func existing(_ path: String) -> String {+ var probe = path+ while !fm.fileExists(atPath: probe), probe != "/", !probe.isEmpty { probe = (probe as NSString).deletingLastPathComponent }+ return probe+ }+ let key = URLResourceKey.volumeIdentifierKey+ guard let x = try? URL(fileURLWithPath: existing(a)).resourceValues(forKeys: [key]).volumeIdentifier,+ let y = try? URL(fileURLWithPath: existing(b)).resourceValues(forKeys: [key]).volumeIdentifier else { return false }+ return x.isEqual(y)+ }++ /// Copies a file, a folder (with what it holds) or a link, links as links. false: stopped.+ private static func copyItem(_ from: String, to: String, fm: FileManager, chunk: Int, done: inout Int64,+ progress: (Int64) -> Void, stop: () -> Bool) throws -> Bool {+ if stop() { return false }+ let attributes = try fm.attributesOfItem(atPath: from)+ let permissions = attributes[.posixPermissions]+ switch attributes[.type] as? FileAttributeType {+ case .typeSymbolicLink?:+ // setting permissions would follow the link, so a link keeps the default ones+ try fm.createSymbolicLink(atPath: to, withDestinationPath: fm.destinationOfSymbolicLink(atPath: from))+ return true+ case .typeDirectory?:+ try fm.createDirectory(atPath: to, withIntermediateDirectories: false)+ for name in try fm.contentsOfDirectory(atPath: from).sorted() {+ guard try copyItem(from + "/" + name, to: to + "/" + name, fm: fm, chunk: chunk, done: &done, progress: progress, stop: stop) else { return false }+ }+ case .typeRegular?:+ guard fm.createFile(atPath: to, contents: nil) else { throw CocoaError(.fileWriteUnknown, userInfo: [NSFilePathErrorKey: to]) }+ let input = try FileHandle(forReadingFrom: URL(fileURLWithPath: from))+ let output = try FileHandle(forWritingTo: URL(fileURLWithPath: to))+ defer { try? input.close(); try? output.close() }+ while true {+ if stop() { return false }+ guard let data = try input.read(upToCount: chunk), !data.isEmpty else { break }+ try output.write(contentsOf: data)+ done += Int64(data.count)+ progress(done)+ }+ try output.synchronize()+ default:+ throw CocoaError(.fileReadUnsupportedScheme, userInfo: [NSFilePathErrorKey: from]) // a socket or a device: not ours+ }+ if let permissions { try fm.setAttributes([.posixPermissions: permissions], ofItemAtPath: to) }+ return true+ }++ private enum Comparison { case same, stopped, different(String) }++ /// The copy holds the same entries as the original: the same kinds, the same link targets and every file byte for byte.+ private static func compare(_ a: String, _ b: String, relative: String, fm: FileManager, chunk: Int, done: inout Int64,+ progress: (Int64) -> Void, stop: () -> Bool) -> Comparison {+ if stop() { return .stopped }+ guard let x = try? fm.attributesOfItem(atPath: a), let y = try? fm.attributesOfItem(atPath: b),+ let kind = x[.type] as? FileAttributeType, kind == y[.type] as? FileAttributeType else { return .different(relative) }+ switch kind {+ case .typeSymbolicLink:+ guard let p = try? fm.destinationOfSymbolicLink(atPath: a), p == (try? fm.destinationOfSymbolicLink(atPath: b)) else { return .different(relative) }+ case .typeDirectory:+ guard let left = try? fm.contentsOfDirectory(atPath: a).sorted(), let right = try? fm.contentsOfDirectory(atPath: b).sorted(),+ left == right else { return .different(relative) }+ for name in left {+ let result = compare(a + "/" + name, b + "/" + name, relative: relative + "/" + name, fm: fm, chunk: chunk, done: &done,+ progress: progress, stop: stop)+ if case .same = result { continue }+ return result+ }+ default:+ guard (x[.size] as? NSNumber)?.int64Value == (y[.size] as? NSNumber)?.int64Value,+ let one = FileHandle(forReadingAtPath: a), let two = FileHandle(forReadingAtPath: b) else { return .different(relative) }+ defer { try? one.close(); try? two.close() }+ while true {+ if stop() { return .stopped }+ // nil and empty both mean the end of the file+ let p = ((try? one.read(upToCount: chunk)) ?? nil) ?? Data(), q = ((try? two.read(upToCount: chunk)) ?? nil) ?? Data()+ guard p == q else { return .different(relative) }+ guard !p.isEmpty else { break }+ done += Int64(p.count)+ progress(done)+ }+ }+ return .same+ }+}diff --git a/frontend/Sources/NXLauncher/ShellCacheRow.swift b/frontend/Sources/NXLauncher/ShellCacheRow.swiftnew file mode 100644index 00000000..17a6e651--- /dev/null+++ b/frontend/Sources/NXLauncher/ShellCacheRow.swift@@ -0,0 +1,169 @@+import SwiftUI+import AppKit+import NXCore+import NXModel++/// Settings, "Tools", the cache row (#400, #427): where the shell cache is, Open folder, and Move cache folder. A move opens a panel+/// under the row: the confirmation (from, to, the sizes, same drive or another), then the progress with Stop, then the result. The+/// way back to the default place is a line under the row while the cache is somewhere else. Observes the build store, whose+/// `running` flag turns the move off while a build, an install or an export runs, and keeps those off while the cache moves.+package struct ShellCacheRow: View {+ @ObservedObject var build: BuildStore+ @EnvironmentObject var loc: Localizer++ package init(build: BuildStore) { self.build = build }++ /// The column where a row's text starts (CardRow: the edge, the dot and its gap).+ private let axis: CGFloat = 37+ private let well = Color.black.opacity(0.22)++ private var moving: Bool { if case .moving = build.shellMove { return true } else { return false } }++ package var body: some View {+ let path = build.shellCachePath+ VStack(alignment: .leading, spacing: 0) {+ CardRow(loc.t("shellCache.row"), detail: loc.t("shellCache.note"), detail2: build.shortPath(path)) {+ Button(loc.t("shellCache.open")) { build.revealFolder(URL(fileURLWithPath: path)) }+ .buttonStyle(LauncherSecondaryButtonStyle())+ Button(loc.t("shellCache.move")) { pickFolder() }+ .buttonStyle(LauncherSecondaryButtonStyle())+ .disabled(build.running)+ .padTarget("set.cacheMove", scope: "main") { if !build.running { pickFolder() } }+ }+ if !build.shellCacheIsDefault, build.shellMove == .idle {+ Button(loc.t("shellCache.useDefault")) { build.prepareShellMoveToDefault() }+ .buttonStyle(.plain).font(.manrope(12.5, .semibold)).foregroundStyle(LauncherPalette.ready)+ .disabled(build.running)+ .padding(.leading, axis).padding(.top, -5).padding(.bottom, 13)+ }+ if build.shellMove != .idle {+ panel.padding(.leading, axis).padding(.trailing, 18).padding(.bottom, 14)+ }+ }+ }++ private func pickFolder() {+ let d = NSOpenPanel()+ d.canChooseDirectories = true; d.canChooseFiles = false; d.canCreateDirectories = true+ d.message = loc.t("shellCache.pickMessage")+ d.prompt = loc.t("shellCache.pickButton")+ if d.runModal() == .OK, let u = d.url { build.prepareShellMove(into: u.path) }+ }++ // MARK: The panel++ @ViewBuilder private var panel: some View {+ VStack(alignment: .leading, spacing: 12) {+ switch build.shellMove {+ case .idle:+ EmptyView()+ case .confirm(let plan):+ confirmation(plan)+ case .moving(let phase, let done, let total):+ let key = phase == .copying ? "shellCache.copying" : "shellCache.checking"+ VStack(alignment: .leading, spacing: 8) {+ LauncherProgressBar(value: total > 0 ? Double(done) / Double(total) : 0, height: 6).frame(height: 6)+ Text(String(format: loc.t(key), ShellInstall.sizeText(done), ShellInstall.sizeText(total)))+ .font(.manrope(12.5)).monospacedDigit().foregroundStyle(.secondary)+ }+ footer(.info, loc.t("shellCache.movingNote")) {+ button(loc.t("btn.stop"), accent: LauncherPalette.building) { build.stopShellMove() }+ }+ case .moved(let root):+ footer(.done, String(format: loc.t("shellCache.moved"), build.shortPath(root))) { ok }+ case .movedOldStays(let root, let old):+ footer(.warning, String(format: loc.t("shellCache.movedOldStays"), build.shortPath(root), build.shortPath(old))) { ok }+ case .stopped(let root):+ footer(.info, String(format: loc.t("shellCache.stopped"), build.shortPath(root))) { ok }+ case .failed(let why, let root):+ footer(.warning, String(format: loc.t("shellCache.failed"), why, build.shortPath(root))) { ok }+ }+ }+ .padding(14)+ .frame(maxWidth: .infinity, alignment: .leading)+ .background(well, in: RoundedRectangle(cornerRadius: 10))+ .overlay(RoundedRectangle(cornerRadius: 10).strokeBorder(Color.white.opacity(0.06)))+ }++ @ViewBuilder private func confirmation(_ plan: ShellRootMove.Plan) -> some View {+ Text(loc.t("shellCache.confirmTitle")).font(.manrope(14, .semibold))+ Grid(alignment: .leadingFirstTextBaseline, horizontalSpacing: 14, verticalSpacing: 6) {+ fact("shellCache.from", build.shortPath(plan.source), path: true)+ fact("shellCache.to", build.shortPath(plan.destination), path: true)+ if plan.sourceExists { fact("shellCache.size", ShellInstall.sizeText(plan.bytes)) }+ if let free = plan.free { fact("shellCache.free", ShellInstall.sizeText(free)) }+ }+ if let problem = plan.problem {+ note(.blocked, problemText(problem))+ } else if !plan.sourceExists {+ note(.info, loc.t("shellCache.nothingYet"))+ } else {+ note(.info, loc.t(plan.sameVolume ? "shellCache.sameDrive" : "shellCache.otherDrive"))+ }+ if build.running { note(.warning, loc.t("shellCache.busy")) }+ buttons {+ button(loc.t("saves.cancel")) { build.dismissShellMove() }+ if plan.problem == nil {+ button(loc.t("shellCache.go"), accent: LauncherPalette.ready, enabled: !build.running) { build.confirmShellMove() }+ }+ }+ }++ private func fact(_ key: String, _ value: String, path: Bool = false) -> some View {+ GridRow {+ Text(loc.t(key)).font(.manrope(12.5)).foregroundStyle(.secondary)+ Text(value).font(path ? .mono(12) : .manrope(12.5, .semibold)).monospacedDigit()+ .lineLimit(1).truncationMode(.middle).help(value)+ .frame(maxWidth: .infinity, alignment: .leading)+ }+ }++ private func problemText(_ problem: ShellRootMove.Problem) -> String {+ switch problem {+ case .same: return loc.t("shellCache.problem.same")+ case .insideCache: return loc.t("shellCache.problem.inside")+ case .notPlain: return loc.t("shellCache.problem.notPlain")+ case .unknownContent: return loc.t("shellCache.problem.unknown")+ case .unreadableLedger: return loc.t("shellCache.problem.ledger")+ case .destinationTaken: return loc.t("shellCache.problem.taken")+ case .readOnly: return loc.t("shellCache.problem.readOnly")+ case .noSpace(let needed, let free):+ return String(format: loc.t("shellCache.problem.noSpace"), ShellInstall.sizeText(needed), ShellInstall.sizeText(free))+ }+ }++ private var ok: some View { button(loc.t("library.ok")) { build.dismissShellMove() } }++ /// A note with its button beside it, on one line when it fits: the progress and the results.+ private func footer<Content: View>(_ kind: NoteKind, _ text: String, @ViewBuilder _ content: () -> Content) -> some View {+ HStack(alignment: .center, spacing: 16) { note(kind, text); content() }+ }++ private func buttons<Content: View>(@ViewBuilder _ content: () -> Content) -> some View {+ HStack(spacing: 10) { Spacer(minLength: 0); content() }+ }++ private func button(_ title: String, accent: Color? = nil, enabled: Bool = true, _ perform: @escaping () -> Void) -> some View {+ Button(title, action: perform).buttonStyle(LauncherSecondaryButtonStyle(accent: accent)).disabled(!enabled).fixedSize()+ }++ private enum NoteKind { case done, info, warning, blocked }++ /// The launcher's note: a small symbol, then the text (as the export's notes, ExportSteps.swift).+ private func note(_ kind: NoteKind, _ text: String) -> some View {+ let (symbol, color): (String, Color) = {+ switch kind {+ case .done: return ("checkmark.circle.fill", LauncherPalette.ready)+ case .info: return ("info.circle", .secondary)+ case .warning: return ("exclamationmark.triangle.fill", LauncherPalette.building)+ case .blocked: return ("exclamationmark.triangle.fill", .red)+ }+ }()+ return HStack(alignment: .firstTextBaseline, spacing: 7) {+ Image(systemName: symbol).font(.system(size: 11, weight: .semibold)).foregroundStyle(color).frame(width: 13)+ Text(text).font(.manrope(12.5)).foregroundStyle(kind == .done || kind == .info ? Color.secondary : color)+ .fixedSize(horizontal: false, vertical: true)+ Spacer(minLength: 0)+ }+ }+}diff --git a/frontend/Sources/NXLauncher/ToolsCard.swift b/frontend/Sources/NXLauncher/ToolsCard.swiftindex 6b9551fc..e6446b42 100644--- a/frontend/Sources/NXLauncher/ToolsCard.swift+++ b/frontend/Sources/NXLauncher/ToolsCard.swift@@ -5,25 +5,23 @@ import NXModel/// Settings, "Tools": the repository or the release app's engine, the dependency rows and the diagnostics row./// Observes the repository, engine sync and dependency stores. What it needs from the build store comes as values:-/// whether a build runs, where the shell cache is and the closure that reveals it. The diagnostics button belongs to the app.-package struct ToolsCard<Diagnostics: View>: View {+/// whether a build runs. The cache row (ShellCacheRow, which observes the build store) and the diagnostics button come as views.+package struct ToolsCard<Diagnostics: View, ShellCache: View>: View {@ObservedObject var repo: RepoStore@ObservedObject var engine: EngineSyncStore@ObservedObject var dependencies: DependencyStorelet buildRunning: Bool- let shellCachePath: String- let revealFolder: (URL) -> Void+ let shellCache: ShellCachelet diagnostics: Diagnostics@EnvironmentObject var loc: Localizer- package init(repo: RepoStore, engine: EngineSyncStore, dependencies: DependencyStore, buildRunning: Bool, shellCachePath: String,- revealFolder: @escaping (URL) -> Void, @ViewBuilder diagnostics: () -> Diagnostics) {+ package init(repo: RepoStore, engine: EngineSyncStore, dependencies: DependencyStore, buildRunning: Bool,+ @ViewBuilder shellCache: () -> ShellCache, @ViewBuilder diagnostics: () -> Diagnostics) {self.repo = repoself.engine = engineself.dependencies = dependenciesself.buildRunning = buildRunning- self.shellCachePath = shellCachePath- self.revealFolder = revealFolder+ self.shellCache = shellCache()self.diagnostics = diagnostics()}@@ -169,10 +167,7 @@ package struct ToolsCard<Diagnostics: View>: View {Text(engine.confirmingChannel.flatMap { engine.selection.channel.switchWarningKey(to: $0) }.map { loc.t($0) } ?? "")}CardDivider()- CardRow(loc.t("shellCache.row"), detail: loc.t("shellCache.note"), detail2: shellCachePath) {- Button(loc.t("shellCache.open")) { revealFolder(URL(fileURLWithPath: shellCachePath)) }- .buttonStyle(LauncherSecondaryButtonStyle())- }+ shellCacheCardDivider()CardRow(loc.t("repo.auto"), detail: loc.t("engine.autoNote")) {Toggle("", isOn: $repo.autoUpdate).labelsHidden().toggleStyle(LauncherSwitchStyle())diff --git a/frontend/Sources/NXModel/BuildStore+ShellRoot.swift b/frontend/Sources/NXModel/BuildStore+ShellRoot.swiftindex 128aa712..56cedba8 100644--- a/frontend/Sources/NXModel/BuildStore+ShellRoot.swift+++ b/frontend/Sources/NXModel/BuildStore+ShellRoot.swift@@ -5,18 +5,118 @@ import NXCore// look only previews the root; a build saves it. An empty parent, "/" or a relative one would have put it at// /NX2Apple-shell, the root of the read-only system volume, where the write failed after the whole build; a saved value// like that is repaired. A build also checks the folder before its long steps, not at the end.+//+// Move cache folder (#427): the player moves the folder to another place, or back to the default one. The move runs on the+// build store's `running` flag, as the copy to a drive does, so no build, install or export starts while it runs, and it+// cannot start while one of them runs. The rules and the file work are ShellRootMove's.++/// The state of Move cache folder, as the cache row shows it.+package enum ShellMove: Equatable {+ case idle+ /// The confirmation: from where to where, the sizes, and what stops it.+ case confirm(ShellRootMove.Plan)+ case moving(phase: ShellRootMove.Phase, done: Int64, total: Int64)+ /// The cache is in its new place (the path).+ case moved(String)+ /// The cache is in its new place, but the old folder could not be removed fully (new place, old place).+ case movedOldStays(String, old: String)+ /// Stopped: the cache stays where it was (the path).+ case stopped(String)+ /// The move failed: the reason, and where the cache stays.+ case failed(String, stays: String)+}extension BuildStore {/// The shell folder the cache row shows: the frameworks' mirror, shell.json and the banner cache live here.- package var shellCachePath: String { ShellLibrary.previewRoot(defaults: defaults, parent: shellRootParent) }+ package var shellCachePath: String { ShellLibrary.previewRoot(defaults: defaults, parent: shellRootParent, home: home) }/// The folder a first shell root would sit in: the output folder, else the game's folder.package var shellRootParent: String { outDir.isEmpty ? (basePath as NSString).deletingLastPathComponent : outDir }/// The shell folder of the install: the saved one, else next to the output folder (or the game's folder).- package var shellRoot: String { ShellLibrary.resolveRoot(defaults: defaults, parent: shellRootParent) }+ package var shellRoot: String { ShellLibrary.resolveRoot(defaults: defaults, parent: shellRootParent, home: home) }/// Why the shell folder cannot be written (`nil`: it can), before an hour of building rather than at the last step.package func shellRootProblem() -> String? {let root = shellRootreturn ShellInstall.canWriteRoot(root) ? nil : String(format: t("shell.rootUnwritable"), shortPath(root))}++ // MARK: Move cache folder++ /// The cache is in the default place, so there is no way back to offer.+ package var shellCacheIsDefault: Bool { shellCachePath == ShellRootMigration.defaultRoot(home: home) }++ /// The confirmation for a move into `folder` (the cache goes into a new folder inside it).+ package func prepareShellMove(into folder: String) {+ prepareShellMove(to: ShellRootMove.destination(inside: folder))+ }++ /// The confirmation for the way back to `~/Library/Application Support/NX2Apple/shell`.+ package func prepareShellMoveToDefault() {+ prepareShellMove(to: ShellRootMigration.defaultRoot(home: home))+ }++ private func prepareShellMove(to destination: String) {+ if case .moving = shellMove { return }+ shellMove = .confirm(ShellRootMove.plan(from: shellCachePath, to: destination))+ }++ /// The confirmed move starts, off the main thread. Refused while a build, an install or an export runs.+ @discardableResult+ package func confirmShellMove() -> Task<Void, Never>? {+ guard !running, case .confirm(let shown) = shellMove else { return nil }+ // Plan again: a build may have written to the cache since the confirmation was shown+ let plan = ShellRootMove.plan(from: shellCachePath, to: shown.destination)+ guard plan.problem == nil else { shellMove = .confirm(plan); return nil }+ running = true+ shellMoveStop.set(false)+ shellMove = .moving(phase: .copying, done: 0, total: plan.bytes)+ let stop = shellMoveStop+ return Task { @MainActor in+ let outcome = await Task.detached(priority: .userInitiated) {+ ShellRootMove.run(plan, progress: { phase, done, total in+ hop { [weak self] in if case .moving = self?.shellMove { self?.shellMove = .moving(phase: phase, done: done, total: total) } }+ }, stop: { stop.value })+ }.value+ self.finishShellMove(plan, outcome)+ }+ }++ /// Stop while the cache moves: the partial copy goes, the old folder stays as it was and keeps being used.+ package func stopShellMove() { shellMoveStop.set(true) }++ /// Back to the plain row, after the confirmation or the result.+ package func dismissShellMove() {+ if case .moving = shellMove { return }+ shellMove = .idle+ }++ private func finishShellMove(_ plan: ShellRootMove.Plan, _ outcome: ShellRootMove.Outcome) {+ running = false+ func saveRoot() {+ defaults.set(plan.destination, forKey: "shellRoot")+ if plan.destination == ShellRootMigration.defaultRoot(home: home) { defaults.removeObject(forKey: ShellRootMove.pickedKey) }+ else { defaults.set(true, forKey: ShellRootMove.pickedKey) }+ }+ switch outcome {+ case .moved:+ saveRoot()+ shellMove = .moved(plan.destination)+ say("Cache folder moved: \(plan.source) → \(plan.destination)")+ case .movedOldStays:+ saveRoot()+ shellMove = .movedOldStays(plan.destination, old: plan.source)+ say("Cache folder moved to \(plan.destination), the old folder \(plan.source) could not be removed fully")+ case .stopped:+ shellMove = .stopped(plan.source)+ case .failed(let failure):+ let why: String+ switch failure {+ case .io(let text): why = text.trimmingCharacters(in: CharacterSet(charactersIn: ".。 ")) // the text goes on after it+ case .mismatch(let path): why = String(format: t("shellCache.fail.mismatch"), path)+ case .ledger: why = t("shellCache.fail.ledger")+ }+ shellMove = .failed(why, stays: plan.source)+ say("Cache folder not moved (\(why)), it stays in \(plan.source)")+ }+ }}diff --git a/frontend/Sources/NXModel/BuildStore.swift b/frontend/Sources/NXModel/BuildStore.swiftindex 6f142ab2..a2b04bbd 100644--- a/frontend/Sources/NXModel/BuildStore.swift+++ b/frontend/Sources/NXModel/BuildStore.swift@@ -141,6 +141,10 @@ func hop(_ body: @escaping @MainActor () -> Void) {var shellRetry: (framework: String, titleID: String, name: String, archive: String)?var shellDeviceChecked = falsepackage let driveCancel = LockedFlag() // Stop of the copy to a drive (BuildStore+Send.swift)+ @Published package var shellMove: ShellMove = .idle // Move cache folder (BuildStore+ShellRoot.swift, #427)+ package let shellMoveStop = LockedFlag()+ /// The home folder the default shell root is in. Tests use a temporary one, so they never touch the real Application Support.+ package var home = NSHomeDirectory()// ---- The app's side: AppKit and the wiring, as closures ----package var chooseKeys: (() -> Void)? // tests stand in for the file picker@@ -228,6 +232,7 @@ func hop(_ body: @escaping @MainActor () -> Void) {package func fail(_ why: String) { running = false; doneNote = why; say("✗ " + why); cleanupStaging() }package func stop() {+ if case .moving = shellMove { stopShellMove(); return }guard running, !stopping, let proc, proc.isRunning else { return }stopping = trueProcessGroups.endGroup(proc.processIdentifier) // the script and every tool it starteddiff --git a/frontend/Tests/NX2AppleTests/ShellCacheCaptureTests.swift b/frontend/Tests/NX2AppleTests/ShellCacheCaptureTests.swiftnew file mode 100644index 00000000..cd46fb04--- /dev/null+++ b/frontend/Tests/NX2AppleTests/ShellCacheCaptureTests.swift@@ -0,0 +1,87 @@+import XCTest+import SwiftUI+import AppKit+@testable import NX2Apple+@testable import NXCore+@testable import NXModel+@testable import NXLauncher++/// Visual QA of Move cache folder, LNPANDY/NX2Apple#427 (matched by --filter testRenderShellCacheForVisualQA). The Tools card of the+/// release app in every state of the move. The states are set on the store, so nothing is moved and no folder is touched: the+/// cache row only reads the saved place, which the test restores.+final class ShellCacheCaptureTests: XCTestCase {+ @MainActor func testRenderShellCacheForVisualQA() throws {+ guard let directory = ProcessInfo.processInfo.environment["NX_LAUNCHER_CAPTURE_DIR"] else { throw XCTSkip("Set NX_LAUNCHER_CAPTURE_DIR to capture native views") }+ let output = URL(fileURLWithPath: directory)+ try FileManager.default.createDirectory(at: output, withIntermediateDirectories: true)+ let lang = CaptureLanguage.current(.en)+ let saved = ["shellRoot", ShellRootMove.pickedKey].map { ($0, UserDefaults.standard.object(forKey: $0)) }+ defer { for (key, value) in saved { UserDefaults.standard.set(value, forKey: key) } }+ UserDefaults.standard.removeObject(forKey: "shellRoot")++ let stores = LauncherStores(); let model = stores.build+ stores.localizer.lang = lang+ stores.engineSync.bundle = URL(fileURLWithPath: "/Applications/NX2Apple.app/Contents/Resources/engine") // the release app's rows+ stores.engineSync.status = ""+ MainActor.assumeIsolated { stores.dependencies.checked = true }+ MainActor.assumeIsolated { stores.dependencies.deps = [Dep(id: "test", name: "Xcode", hint: "", present: true, installCmd: [])] }++ func shot(_ name: String) throws {+ let card = ToolsCard(repo: stores.repo, engine: stores.engineSync, dependencies: stores.dependencies, buildRunning: model.running,+ shellCache: { ShellCacheRow(build: model) }) { DiagnosticsButton(report: { _, _ in }) }+ let framed = card.environmentObject(stores.localizer).environmentObject(PadFocus()).padding(24).frame(width: 860).background(Color(white: 0.09)).environment(\.colorScheme, .dark)+ NSApplication.shared.setActivationPolicy(.accessory)+ let host = NSHostingView(rootView: framed)+ host.frame = NSRect(origin: .zero, size: host.fittingSize)+ host.wantsLayer = true+ host.layer?.backgroundColor = NSColor(white: 0.09, alpha: 1).cgColor+ let window = OffscreenWindow(size: host.frame.size)+ window.contentView = host+ window.orderFront(nil)+ RunLoop.main.run(until: Date().addingTimeInterval(0.4))+ host.layoutSubtreeIfNeeded()+ let rep = try XCTUnwrap(host.bitmapImageRepForCachingDisplay(in: host.bounds))+ host.cacheDisplay(in: host.bounds, to: rep)+ try XCTUnwrap(rep.representation(using: .png, properties: [:])).write(to: output.appendingPathComponent("cache-\(name)-\(lang.code).png"))+ window.orderOut(nil)+ }++ let home = NSHomeDirectory(), defaultRoot = ShellRootMigration.defaultRoot(home: home)+ let drive = "/Volumes/T7 Shield/Switch/NX2Apple-shell"+ try shot("0-default")++ model.shellMove = .confirm(ShellRootMove.Plan(source: defaultRoot, destination: drive, bytes: 23_400_000_000, free: 812_000_000_000,+ sameVolume: false, sourceExists: true, problem: nil))+ try shot("1-confirm-other-drive")+ model.shellMove = .confirm(ShellRootMove.Plan(source: defaultRoot, destination: home + "/Games/NX2Apple-shell", bytes: 23_400_000_000,+ free: 96_000_000_000, sameVolume: true, sourceExists: true, problem: nil))+ try shot("2-confirm-same-drive")+ model.shellMove = .confirm(ShellRootMove.Plan(source: defaultRoot, destination: drive, bytes: 23_400_000_000, free: 9_100_000_000,+ sameVolume: false, sourceExists: true, problem: .noSpace(needed: 23_400_000_000, free: 9_100_000_000)))+ try shot("3-no-space")+ model.shellMove = .confirm(ShellRootMove.Plan(source: defaultRoot, destination: drive, bytes: 23_400_000_000, free: 812_000_000_000,+ sameVolume: false, sourceExists: true, problem: nil))+ model.running = true+ try shot("4-build-running")+ model.shellMove = .moving(phase: .copying, done: 8_700_000_000, total: 23_400_000_000)+ try shot("5-copying")+ model.shellMove = .moving(phase: .checking, done: 17_900_000_000, total: 23_400_000_000)+ try shot("6-checking")+ model.running = false+ model.shellMove = .stopped(defaultRoot)+ try shot("7-stopped")+ model.shellMove = .failed("The disk “T7 Shield” was ejected", stays: defaultRoot) // the store drops the system text's full stop+ try shot("8-failed")++ UserDefaults.standard.set(drive, forKey: "shellRoot") // read only: the row shows the saved place+ model.shellMove = .moved(drive)+ try shot("9-moved")+ model.shellMove = .movedOldStays(drive, old: defaultRoot)+ try shot("10-moved-old-stays")+ model.shellMove = .idle+ try shot("11-custom-place")+ model.shellMove = .confirm(ShellRootMove.Plan(source: drive, destination: defaultRoot, bytes: 23_400_000_000, free: 96_000_000_000,+ sameVolume: false, sourceExists: true, problem: nil))+ try shot("12-back-to-default")+ }+}diff --git a/frontend/Tests/NXCoreTests/ShellRootMoveTests.swift b/frontend/Tests/NXCoreTests/ShellRootMoveTests.swiftnew file mode 100644index 00000000..8c66f4a5--- /dev/null+++ b/frontend/Tests/NXCoreTests/ShellRootMoveTests.swift@@ -0,0 +1,257 @@+import XCTest+@testable import NXCore++/// LNPANDY/NX2Apple#427, Move cache folder. Every test runs in a temporary folder with its own `home`, so the real Application+/// Support folder is never touched. The bug class is data loss: the old folder must survive every stop and every failure, and is+/// removed only after its copy was checked file by file. The copy to another volume is tested on one volume by setting+/// `sameVolume` to false in the plan, which takes the same code path as a real external drive.+final class ShellRootMoveTests: XCTestCase {+ private let fm = FileManager.default+ private var base: String!+ private var home: String { base + "/home" }+ private var source: String { home + "/Library/Application Support/NX2Apple/shell" }+ private var picked: String { base + "/Drive/Games" }+ private var destination: String { ShellRootMove.destination(inside: picked) }+ private var buildFramework: String { base + "/Out/build/DmGame0100BBBB.framework" }++ override func setUpWithError() throws {+ base = fm.temporaryDirectory.path + "/nspb-move-" + UUID().uuidString+ try fm.createDirectory(atPath: picked, withIntermediateDirectories: true)+ }++ override func tearDownWithError() throws {+ // a test makes a file unreadable: make everything removable again+ if let walker = fm.enumerator(atPath: base) {+ for case let path as String in walker { try? fm.setAttributes([.posixPermissions: 0o755], ofItemAtPath: base + "/" + path) }+ }+ try? fm.removeItem(atPath: base)+ }++ /// A cache as the launcher makes it: a mirrored framework with an executable and a link (listed in shell.json), the project, the+ /// derived data and a framework in a build folder that is not inside the cache.+ private func makeCache(big: Int = 64 * 1024) throws {+ let mirror = source + "/frameworks/DmGame0100AAAA.framework"+ for dir in [mirror, source + "/project", source + "/derived-data/Build", buildFramework] {+ try fm.createDirectory(atPath: dir, withIntermediateDirectories: true)+ }+ try Data((0..<big).map { UInt8($0 % 251) }).write(to: URL(fileURLWithPath: mirror + "/DmGame0100AAAA"))+ try fm.setAttributes([.posixPermissions: 0o755], ofItemAtPath: mirror + "/DmGame0100AAAA")+ try Data("{\"manifest\":1}".utf8).write(to: URL(fileURLWithPath: mirror + "/game.manifest.json"))+ try fm.createSymbolicLink(atPath: mirror + "/Current", withDestinationPath: "DmGame0100AAAA")+ try Data("project".utf8).write(to: URL(fileURLWithPath: source + "/project/project.yml"))+ let json: [String: Any] = ["bundleID": "org.nxnative.shell.TEAM", "team": "TEAM", "futureKey": 7,+ "games": [["titleID": "0100AAAA", "name": "A", "framework": mirror],+ ["titleID": "0100BBBB", "name": "B", "framework": buildFramework]]]+ try JSONSerialization.data(withJSONObject: json).write(to: URL(fileURLWithPath: source + "/shell.json"))+ }++ /// Every entry under `root` with its kind and content, to see that a folder is exactly as it was.+ private func snapshot(_ root: String) -> [String: String] {+ var out: [String: String] = [:]+ guard let walker = fm.enumerator(atPath: root) else { return out }+ for case let path as String in walker {+ let full = root + "/" + path+ if let link = try? fm.destinationOfSymbolicLink(atPath: full) { out[path] = "link:" + link; continue }+ var isDir: ObjCBool = false+ fm.fileExists(atPath: full, isDirectory: &isDir)+ out[path] = isDir.boolValue ? "dir" : (fm.contents(atPath: full)?.base64EncodedString() ?? "unreadable")+ }+ return out+ }++ private func frameworks(_ root: String) throws -> [String] {+ let data = try XCTUnwrap(fm.contents(atPath: root + "/shell.json"))+ let json = try XCTUnwrap(JSONSerialization.jsonObject(with: data) as? [String: Any])+ XCTAssertEqual(json["futureKey"] as? Int, 7, "a key this version does not know stays")+ return (json["games"] as? [[String: Any]] ?? []).compactMap { $0["framework"] as? String }+ }++ private func leftovers() throws -> [String] {+ try fm.contentsOfDirectory(atPath: picked).filter { $0.contains("-moving-") }+ }++ private func crossVolumePlan() -> ShellRootMove.Plan {+ var plan = ShellRootMove.plan(from: source, to: destination)+ plan.sameVolume = false+ return plan+ }++ // MARK: The moves++ func testOnTheSameVolumeTheFolderIsRenamedAndShellJsonNamesTheNewPlace() throws {+ try makeCache()+ let before = snapshot(source)+ let plan = ShellRootMove.plan(from: source, to: destination)+ XCTAssertNil(plan.problem)+ XCTAssertTrue(plan.sameVolume, "a temporary folder and its neighbour are on one volume")+ XCTAssertTrue(plan.sourceExists)+ XCTAssertGreaterThan(plan.bytes, 64 * 1024)+ XCTAssertEqual(ShellRootMove.run(plan), .moved)+ XCTAssertFalse(fm.fileExists(atPath: source))+ XCTAssertEqual(snapshot(destination).keys.sorted(), before.keys.sorted())+ XCTAssertEqual(try frameworks(destination), [destination + "/frameworks/DmGame0100AAAA.framework", buildFramework],+ "the mirror moved with the cache, the build folder's framework did not")+ }++ func testOnAnotherVolumeEveryFileIsCopiedCheckedAndOnlyThenTheOldFolderGoes() throws {+ try makeCache()+ let before = snapshot(source)+ var phases: [ShellRootMove.Phase] = []+ let outcome = ShellRootMove.run(crossVolumePlan(), chunk: 4096, progress: { phase, _, _ in+ if phases.last != phase { phases.append(phase) }+ })+ XCTAssertEqual(outcome, .moved)+ XCTAssertEqual(phases, [.copying, .checking], "the copy is checked after it is made")+ XCTAssertFalse(fm.fileExists(atPath: source), "the old folder is removed after the checked copy took its place")+ var after = snapshot(destination), expected = before+ after["shell.json"] = nil; expected["shell.json"] = nil // rewritten for the new place, checked below+ XCTAssertEqual(after, expected, "the same files, the same bytes, the link as a link")+ let binary = destination + "/frameworks/DmGame0100AAAA.framework/DmGame0100AAAA"+ XCTAssertEqual((try fm.attributesOfItem(atPath: binary)[.posixPermissions] as? NSNumber)?.intValue, 0o755, "the permissions are kept")+ XCTAssertEqual(try frameworks(destination), [destination + "/frameworks/DmGame0100AAAA.framework", buildFramework])+ XCTAssertEqual(try leftovers(), [], "no hidden copy is left")+ }++ func testAStopWhileCopyingLeavesTheOldFolderExactlyAsItWas() throws {+ try makeCache()+ let before = snapshot(source)+ var copied: Int64 = 0+ let outcome = ShellRootMove.run(crossVolumePlan(), chunk: 1024, progress: { phase, done, _ in if phase == .copying { copied = done } },+ stop: { copied > 8 * 1024 })+ XCTAssertEqual(outcome, .stopped)+ XCTAssertEqual(snapshot(source), before, "the old folder is untouched and stays valid")+ XCTAssertFalse(fm.fileExists(atPath: destination))+ XCTAssertEqual(try leftovers(), [], "the partial copy is removed")+ }++ func testAStopWhileCheckingLeavesTheOldFolderExactlyAsItWas() throws {+ try makeCache()+ let before = snapshot(source)+ var checking = false+ let outcome = ShellRootMove.run(crossVolumePlan(), chunk: 1024, progress: { phase, done, _ in if phase == .checking, done > 4096 { checking = true } },+ stop: { checking })+ XCTAssertEqual(outcome, .stopped)+ XCTAssertEqual(snapshot(source), before)+ XCTAssertFalse(fm.fileExists(atPath: destination))+ XCTAssertEqual(try leftovers(), [])+ }++ /// The bug class: a copy that is not the same as its original (a drive that wrote wrong bytes) must never cost the old folder.+ func testACopyThatDiffersFromTheOriginalKeepsTheOldFolderAndRemovesTheCopy() throws {+ try makeCache()+ let before = snapshot(source)+ let outcome = ShellRootMove.run(crossVolumePlan(), afterCopy: { staging in+ let binary = staging + "/frameworks/DmGame0100AAAA.framework/DmGame0100AAAA"+ var data = self.fm.contents(atPath: binary)!+ data[100] ^= 0xFF // one wrong byte, the same size+ try? data.write(to: URL(fileURLWithPath: binary))+ })+ XCTAssertEqual(outcome, .failed(.mismatch("frameworks/DmGame0100AAAA.framework/DmGame0100AAAA")))+ XCTAssertEqual(snapshot(source), before, "nothing of the old folder was removed")+ XCTAssertFalse(fm.fileExists(atPath: destination))+ XCTAssertEqual(try leftovers(), [])+ }++ func testAMissingFileInTheCopyKeepsTheOldFolder() throws {+ try makeCache()+ let before = snapshot(source)+ let outcome = ShellRootMove.run(crossVolumePlan(), afterCopy: { try? self.fm.removeItem(atPath: $0 + "/project/project.yml") })+ XCTAssertEqual(outcome, .failed(.mismatch("project")))+ XCTAssertEqual(snapshot(source), before)+ XCTAssertFalse(fm.fileExists(atPath: destination))+ }++ func testAFileThatCannotBeReadStopsTheCopyAndKeepsTheOldFolder() throws {+ try makeCache()+ let unreadable = source + "/project/project.yml"+ try fm.setAttributes([.posixPermissions: 0o000], ofItemAtPath: unreadable)+ let outcome = ShellRootMove.run(crossVolumePlan())+ guard case .failed(.io) = outcome else { return XCTFail("expected a failed copy, got \(outcome)") }+ try fm.setAttributes([.posixPermissions: 0o644], ofItemAtPath: unreadable)+ XCTAssertEqual(fm.contents(atPath: unreadable), Data("project".utf8), "the old folder keeps its files")+ XCTAssertTrue(fm.fileExists(atPath: source + "/shell.json"))+ XCTAssertFalse(fm.fileExists(atPath: destination))+ XCTAssertEqual(try leftovers(), [])+ }++ func testWithNoCacheYetOnlyThePlaceChanges() throws {+ let plan = ShellRootMove.plan(from: source, to: destination)+ XCTAssertNil(plan.problem)+ XCTAssertFalse(plan.sourceExists)+ XCTAssertEqual(plan.bytes, 0)+ XCTAssertEqual(ShellRootMove.run(plan), .moved)+ XCTAssertFalse(fm.fileExists(atPath: destination), "the folder is made by the next install, as for a new player")+ }++ /// The folder the player picks is never the launcher's: the cache goes into a folder of its own inside it, and moving the cache+ /// away again removes only that folder, never the player's other files.+ func testThePickedFolderAndItsOtherFilesStayWhenTheCacheMovesAwayAgain() throws {+ try makeCache()+ try Data("mine".utf8).write(to: URL(fileURLWithPath: picked + "/notes.txt"))+ XCTAssertEqual(destination, picked + "/NX2Apple-shell")+ XCTAssertEqual(ShellRootMove.run(crossVolumePlan()), .moved)+ var back = ShellRootMove.plan(from: destination, to: source)+ back.sameVolume = false+ XCTAssertNil(back.problem)+ XCTAssertEqual(ShellRootMove.run(back), .moved)+ XCTAssertEqual(fm.contents(atPath: picked + "/notes.txt"), Data("mine".utf8))+ XCTAssertEqual(try fm.contentsOfDirectory(atPath: picked), ["notes.txt"])+ XCTAssertEqual(try frameworks(source), [source + "/frameworks/DmGame0100AAAA.framework", buildFramework])+ }++ func testAnEmptyFolderAtTheDestinationIsTakenOver() throws {+ try makeCache()+ try fm.createDirectory(atPath: destination, withIntermediateDirectories: true)+ try Data().write(to: URL(fileURLWithPath: destination + "/.DS_Store"))+ XCTAssertNil(ShellRootMove.plan(from: source, to: destination).problem)+ XCTAssertEqual(ShellRootMove.run(crossVolumePlan()), .moved)+ XCTAssertTrue(fm.fileExists(atPath: destination + "/shell.json"))+ }++ // MARK: What stops a move before it starts++ func testTheSafetyRulesOfTheMigrationHold() throws {+ try makeCache()+ XCTAssertEqual(ShellRootMove.plan(from: source, to: source).problem, .same)+ XCTAssertEqual(ShellRootMove.plan(from: source, to: source + "/frameworks/NX2Apple-shell").problem, .insideCache)++ try fm.createDirectory(atPath: destination + "/frameworks", withIntermediateDirectories: true)+ XCTAssertEqual(ShellRootMove.plan(from: source, to: destination).problem, .destinationTaken, "a folder with content is never overwritten")+ try fm.removeItem(atPath: destination)+ try fm.createSymbolicLink(atPath: destination, withDestinationPath: base)+ XCTAssertEqual(ShellRootMove.plan(from: source, to: destination).problem, .destinationTaken, "a link at the destination is not free")+ try fm.removeItem(atPath: destination)++ try Data("{not json".utf8).write(to: URL(fileURLWithPath: source + "/shell.json"))+ XCTAssertEqual(ShellRootMove.plan(from: source, to: destination).problem, .unreadableLedger)+ try fm.removeItem(atPath: source + "/shell.json")+ XCTAssertEqual(ShellRootMove.plan(from: source, to: destination).problem, .unknownContent, "files and no shell.json: not a cache we know")++ let link = base + "/linked-shell"+ try fm.createSymbolicLink(atPath: link, withDestinationPath: source)+ XCTAssertEqual(ShellRootMove.plan(from: link, to: destination).problem, .notPlain)+ // a plan with a problem never runs, even when a caller skips the check+ XCTAssertEqual(ShellRootMove.run(ShellRootMove.plan(from: link, to: destination)), .failed(.io("the move cannot start")))+ XCTAssertTrue(fm.fileExists(atPath: source + "/project/project.yml"))+ }++ // MARK: The saved root++ /// A cache the player moved into `<folder>/NX2Apple-shell` is named like an old one in an output folder. The migration at+ /// launch must not move it back to Application Support.+ func testAPickedRootIsNotMigratedBackAtLaunch() throws {+ try makeCache()+ XCTAssertEqual(ShellRootMove.run(ShellRootMove.plan(from: source, to: destination)), .moved)+ let defaults = UserDefaults(suiteName: "nspb-move-" + UUID().uuidString)!+ defaults.set(destination, forKey: "shellRoot")+ defaults.set(true, forKey: ShellRootMove.pickedKey)+ ShellRootMigration.migrateSavedRoot(defaults: defaults, home: home)+ XCTAssertEqual(ShellLibrary.resolveRoot(defaults: defaults, parent: base + "/Out", home: home), destination)+ XCTAssertTrue(fm.fileExists(atPath: destination + "/shell.json"))+ XCTAssertFalse(fm.fileExists(atPath: source))++ defaults.removeObject(forKey: ShellRootMove.pickedKey) // the same folder from an older version still moves+ XCTAssertEqual(ShellLibrary.resolveRoot(defaults: defaults, parent: base + "/Out", home: home), source)+ XCTAssertTrue(fm.fileExists(atPath: source + "/shell.json"))+ }+}diff --git a/frontend/Tests/NXModelTests/BuildStoreTests.swift b/frontend/Tests/NXModelTests/BuildStoreTests.swiftindex db95e7a6..243d612a 100644--- a/frontend/Tests/NXModelTests/BuildStoreTests.swift+++ b/frontend/Tests/NXModelTests/BuildStoreTests.swift@@ -340,4 +340,97 @@ import XCTeststore.stop()XCTAssertFalse(store.stopping)}++ // MARK: Move cache folder (#427)++ /// A store whose home is the temporary folder, so the default cache place is never the real Application Support.+ private func moveStore() throws -> (BuildStore, cache: String) {+ let store = makeStore()+ store.home = temporary.path + "/home"+ let cache = store.home + "/Library/Application Support/NX2Apple/shell"+ try FileManager.default.createDirectory(atPath: cache + "/frameworks/DmGame0100AAAA.framework", withIntermediateDirectories: true)+ try Data("shader".utf8).write(to: URL(fileURLWithPath: cache + "/frameworks/DmGame0100AAAA.framework/game.manifest.json"))+ let json: [String: Any] = ["bundleID": "org.nxnative.shell.TEAM", "team": "TEAM", "games": [["titleID": "0100AAAA", "name": "A", "framework": cache + "/frameworks/DmGame0100AAAA.framework"]]]+ try JSONSerialization.data(withJSONObject: json).write(to: URL(fileURLWithPath: cache + "/shell.json"))+ XCTAssertEqual(store.shellCachePath, cache)+ XCTAssertTrue(store.shellCacheIsDefault)+ return (store, cache)+ }++ /// The build guard: no move starts while a build, an install or an export runs, and nothing on disk changes.+ func testTheCacheDoesNotMoveWhileABuildRuns() throws {+ let (store, cache) = try moveStore()+ let picked = temporary.path + "/Drive"+ try FileManager.default.createDirectory(atPath: picked, withIntermediateDirectories: true)+ store.prepareShellMove(into: picked)+ guard case .confirm(let plan) = store.shellMove else { return XCTFail("the confirmation shows") }+ XCTAssertEqual(plan.destination, picked + "/NX2Apple-shell")+ store.running = true+ XCTAssertNil(store.confirmShellMove(), "refused while a build runs")+ XCTAssertEqual(store.shellMove, .confirm(plan), "the confirmation stays, with its note")+ XCTAssertTrue(FileManager.default.fileExists(atPath: cache + "/shell.json"))+ XCTAssertFalse(FileManager.default.fileExists(atPath: plan.destination))+ XCTAssertNil(defaults.string(forKey: "shellRoot"), "the saved place is unchanged")+ }++ /// While the cache moves the build store's `running` flag is set, so no build can start, and the saved place, shell.json and the+ /// way back follow the move.+ func testAMoveSavesTheNewPlaceAndTheWayBackClearsThePick() async throws {+ let (store, cache) = try moveStore()+ let picked = temporary.path + "/Drive"+ try FileManager.default.createDirectory(atPath: picked, withIntermediateDirectories: true)+ store.prepareShellMove(into: picked)+ let task = try XCTUnwrap(store.confirmShellMove())+ XCTAssertTrue(store.running, "builds, installs and exports are off while the cache moves")+ XCTAssertFalse(store.canBuild)+ await task.value+ let moved = picked + "/NX2Apple-shell"+ XCTAssertEqual(store.shellMove, .moved(moved))+ XCTAssertFalse(store.running)+ XCTAssertEqual(defaults.string(forKey: "shellRoot"), moved)+ XCTAssertTrue(defaults.bool(forKey: ShellRootMove.pickedKey))+ XCTAssertEqual(store.shellCachePath, moved)+ XCTAssertEqual(store.shellRoot, moved, "the launch migration leaves a picked folder where it is")+ XCTAssertFalse(store.shellCacheIsDefault)+ XCTAssertFalse(FileManager.default.fileExists(atPath: cache))+ XCTAssertEqual(ShellLibrary.load(root: moved).games.first?.framework, moved + "/frameworks/DmGame0100AAAA.framework")++ store.dismissShellMove()+ store.prepareShellMoveToDefault()+ await store.confirmShellMove()?.value+ XCTAssertEqual(store.shellMove, .moved(cache))+ XCTAssertEqual(defaults.string(forKey: "shellRoot"), cache)+ XCTAssertFalse(defaults.bool(forKey: ShellRootMove.pickedKey))+ XCTAssertTrue(store.shellCacheIsDefault)+ XCTAssertEqual(try FileManager.default.contentsOfDirectory(atPath: picked), [], "the picked folder stays, empty as it was")+ }++ /// A move that fails on the disk says why and where the cache stays, keeps the old folder and the saved place.+ func testAFailedMoveKeepsTheCacheAndTheSavedPlace() async throws {+ let (store, cache) = try moveStore()+ let picked = temporary.path + "/Locked"+ try FileManager.default.createDirectory(atPath: picked, withIntermediateDirectories: true)+ try FileManager.default.setAttributes([.posixPermissions: 0o555], ofItemAtPath: picked) // nothing can be made inside it+ defer { try? FileManager.default.setAttributes([.posixPermissions: 0o755], ofItemAtPath: picked) }+ store.prepareShellMove(into: picked)+ await store.confirmShellMove()?.value+ guard case .failed(let why, let stays) = store.shellMove else { return XCTFail("expected a failure, got \(store.shellMove)") }+ XCTAssertFalse(why.isEmpty)+ XCTAssertFalse(why.hasSuffix("."), "the text goes on after the reason, so the system's full stop is dropped")+ XCTAssertEqual(stays, cache)+ XCTAssertFalse(store.running)+ XCTAssertTrue(FileManager.default.fileExists(atPath: cache + "/frameworks/DmGame0100AAAA.framework/game.manifest.json"))+ XCTAssertNil(defaults.string(forKey: "shellRoot"))+ XCTAssertFalse(defaults.bool(forKey: ShellRootMove.pickedKey))+ }++ func testAMoveThatCannotStartKeepsTheSavedPlace() throws {+ let (store, cache) = try moveStore()+ store.prepareShellMove(into: cache + "/frameworks")+ guard case .confirm(let plan) = store.shellMove else { return XCTFail("the confirmation shows") }+ XCTAssertEqual(plan.problem, .insideCache)+ XCTAssertNil(store.confirmShellMove())+ XCTAssertFalse(store.running)+ XCTAssertNil(defaults.string(forKey: "shellRoot"))+ }}diff --git a/frontend/l10n/de.json b/frontend/l10n/de.jsonindex 42b02c39..3e315ae8 100644--- a/frontend/l10n/de.json+++ b/frontend/l10n/de.json@@ -1133,9 +1133,40 @@"shell.step3Title": "Spieldaten senden","shell.whereDevice": "Gerät","shell.whereDrive": "Laufwerk oder Ordner",+ "shellCache.busy": "Ein Build oder eine Installation läuft. Verschiebe den Cache danach.",+ "shellCache.checking": "Prüfe die Kopie, %@ von %@",+ "shellCache.confirmTitle": "Cache-Ordner verschieben?",+ "shellCache.copying": "Kopiere, %@ von %@",+ "shellCache.fail.ledger": "shell.json konnte nicht aktualisiert werden",+ "shellCache.fail.mismatch": "die Kopie von %@ stimmt nicht mit dem Original überein",+ "shellCache.failed": "Der Cache konnte nicht verschoben werden: %@. Er bleibt in %@ und wird weiter benutzt.",+ "shellCache.free": "Dort frei",+ "shellCache.from": "Von",+ "shellCache.go": "Verschieben",+ "shellCache.move": "Verschieben…",+ "shellCache.moved": "Der Cache liegt jetzt in %@.",+ "shellCache.movedOldStays": "Der Cache liegt jetzt in %@. Einige Dateien des alten Ordners ließen sich nicht entfernen. Du kannst %@ im Finder löschen.",+ "shellCache.movingNote": "Der alte Ordner bleibt, bis die Kopie geprüft ist. Stopp lässt ihn, wie er war.","shellCache.note": "Der iPhone-Frameworks-Cache, aufbewahrt für die Installation mehrerer Spiele. Beim Löschen entfernt die Installation eines neuen Spiels die älteren Spiele aus der Shell.",+ "shellCache.nothingYet": "Es gibt noch keinen Cache. Neue Installationen nutzen den neuen Ort.","shellCache.open": "Ordner öffnen",+ "shellCache.otherDrive": "Der neue Ort ist auf einem anderen Laufwerk. Die Dateien werden kopiert und geprüft, dann wird der alte Ordner entfernt. Geht etwas schief, bleibt der alte Ordner und wird weiter benutzt.",+ "shellCache.pickButton": "Wählen",+ "shellCache.pickMessage": "Wähle, wohin der Cache kommt. Er zieht in einen neuen Ordner im gewählten Ordner.",+ "shellCache.problem.inside": "Dieser Ordner liegt im Cache. Wähle einen anderen.",+ "shellCache.problem.ledger": "Die shell.json des Caches ist nicht lesbar, deshalb wird der Ordner nicht verschoben.",+ "shellCache.problem.noSpace": "Nicht genug Platz auf dem Laufwerk: Der Cache braucht %@, %@ sind frei.",+ "shellCache.problem.notPlain": "Der Cache-Ordner ist ein Link oder kein normaler Ordner, deshalb wird er nicht verschoben.",+ "shellCache.problem.readOnly": "Dieses Laufwerk ist schreibgeschützt. Wähle ein anderes.",+ "shellCache.problem.same": "Der Cache ist schon in diesem Ordner.",+ "shellCache.problem.taken": "Im gewählten Ordner gibt es schon einen Cache-Ordner. Wähle einen anderen Ordner oder verschiebe ihn vorher.",+ "shellCache.problem.unknown": "Der Cache-Ordner enthält Dateien, die nicht vom Launcher stammen, deshalb wird er nicht verschoben.","shellCache.row": "Cachedateien",+ "shellCache.sameDrive": "Der neue Ort ist auf demselben Laufwerk. Der Ordner wird sofort verschoben, nichts wird kopiert.",+ "shellCache.size": "Größe",+ "shellCache.stopped": "Gestoppt. Nichts hat sich geändert, der Cache bleibt in %@.",+ "shellCache.to": "Nach",+ "shellCache.useDefault": "Zurück an den Standardort","stage.address_regions": "Adressbereiche","stage.app_build": "App bauen","stage.build_id_lookup": "Build-ID suchen",diff --git a/frontend/l10n/en.json b/frontend/l10n/en.jsonindex 32e52638..1d0f444c 100644--- a/frontend/l10n/en.json+++ b/frontend/l10n/en.json@@ -1259,9 +1259,40 @@"shell.step3Title": "Send the game data","shell.whereDevice": "Device","shell.whereDrive": "Drive or folder",+ "shellCache.busy": "A build or an install is running. Move the cache when it is done.",+ "shellCache.checking": "Checking the copy, %@ of %@",+ "shellCache.confirmTitle": "Move the cache folder?",+ "shellCache.copying": "Copying, %@ of %@",+ "shellCache.fail.ledger": "shell.json could not be updated",+ "shellCache.fail.mismatch": "the copy of %@ is not the same as the original",+ "shellCache.failed": "The cache could not be moved: %@. It stays in %@ and keeps being used.",+ "shellCache.free": "Free there",+ "shellCache.from": "From",+ "shellCache.go": "Move",+ "shellCache.move": "Move folder…",+ "shellCache.moved": "The cache is now in %@.",+ "shellCache.movedOldStays": "The cache is now in %@. Some files of the old folder could not be removed. You can delete %@ in the Finder.",+ "shellCache.movingNote": "The old folder stays until the copy is checked. Stop leaves it as it was.","shellCache.note": "The cache of the iPhone frameworks, kept so several games can be installed. Delete it and installing a new game removes the older games from the shell.",+ "shellCache.nothingYet": "There is no cache yet. New installs use the new place.","shellCache.open": "Open folder",+ "shellCache.otherDrive": "The new place is on another drive. The files are copied and checked, then the old folder is removed. If anything fails, the old folder stays and keeps being used.",+ "shellCache.pickButton": "Choose",+ "shellCache.pickMessage": "Choose where the cache goes. It moves into a new folder inside the folder you choose.",+ "shellCache.problem.inside": "This folder is inside the cache. Choose another one.",+ "shellCache.problem.ledger": "The cache’s shell.json cannot be read, so the folder is not moved.",+ "shellCache.problem.noSpace": "Not enough space on the drive: the cache needs %@, %@ is free.",+ "shellCache.problem.notPlain": "The cache folder is a link or not a plain folder, so it is not moved.",+ "shellCache.problem.readOnly": "This drive is read-only. Choose another one.",+ "shellCache.problem.same": "The cache is already in this folder.",+ "shellCache.problem.taken": "The chosen folder already holds a cache folder. Choose another folder or move that one away first.",+ "shellCache.problem.unknown": "The cache folder holds files the launcher did not make, so it is not moved.","shellCache.row": "Cache files",+ "shellCache.sameDrive": "The new place is on the same drive. The folder moves at once and nothing is copied.",+ "shellCache.size": "Size",+ "shellCache.stopped": "Stopped. Nothing changed, the cache stays in %@.",+ "shellCache.to": "To",+ "shellCache.useDefault": "Move back to the default place","stage.address_regions": "address regions","stage.app_build": "app build","stage.build_id_lookup": "build ID lookup",diff --git a/frontend/l10n/fr.json b/frontend/l10n/fr.jsonindex 7509a532..5da725b8 100644--- a/frontend/l10n/fr.json+++ b/frontend/l10n/fr.json@@ -1135,9 +1135,40 @@"shell.step3Title": "Envoyer les données du jeu","shell.whereDevice": "Appareil","shell.whereDrive": "Disque ou dossier",+ "shellCache.busy": "Une compilation ou une installation est en cours. Déplacez le cache quand elle est terminée.",+ "shellCache.checking": "Vérification de la copie, %@ sur %@",+ "shellCache.confirmTitle": "Déplacer le dossier de cache ?",+ "shellCache.copying": "Copie, %@ sur %@",+ "shellCache.fail.ledger": "shell.json n’a pas pu être mis à jour",+ "shellCache.fail.mismatch": "la copie de %@ ne correspond pas à l’original",+ "shellCache.failed": "Le cache n’a pas pu être déplacé : %@. Il reste dans %@ et continue de servir.",+ "shellCache.free": "Libre là-bas",+ "shellCache.from": "De",+ "shellCache.go": "Déplacer",+ "shellCache.move": "Déplacer…",+ "shellCache.moved": "Le cache est maintenant dans %@.",+ "shellCache.movedOldStays": "Le cache est maintenant dans %@. Certains fichiers de l’ancien dossier n’ont pas pu être supprimés. Vous pouvez supprimer %@ dans le Finder.",+ "shellCache.movingNote": "L’ancien dossier reste jusqu’à ce que la copie soit vérifiée. Arrêter le laisse tel quel.","shellCache.note": "Le cache des frameworks iPhone, conservé pour installer plusieurs jeux. Le supprimer fait qu’installer un nouveau jeu retire les jeux plus anciens de la coque.",+ "shellCache.nothingYet": "Il n’y a pas encore de cache. Les prochaines installations utilisent le nouvel emplacement.","shellCache.open": "Ouvrir le dossier",+ "shellCache.otherDrive": "Le nouvel emplacement est sur un autre disque. Les fichiers sont copiés et vérifiés, puis l’ancien dossier est supprimé. En cas d’échec, l’ancien dossier reste et continue de servir.",+ "shellCache.pickButton": "Choisir",+ "shellCache.pickMessage": "Choisissez où va le cache. Il est déplacé dans un nouveau dossier à l’intérieur du dossier choisi.",+ "shellCache.problem.inside": "Ce dossier est à l’intérieur du cache. Choisissez-en un autre.",+ "shellCache.problem.ledger": "Le fichier shell.json du cache est illisible, le dossier n’est donc pas déplacé.",+ "shellCache.problem.noSpace": "Pas assez d’espace sur le disque : le cache demande %@, %@ libres.",+ "shellCache.problem.notPlain": "Le dossier de cache est un lien ou n’est pas un dossier ordinaire, il n’est donc pas déplacé.",+ "shellCache.problem.readOnly": "Ce disque est en lecture seule. Choisissez-en un autre.",+ "shellCache.problem.same": "Le cache est déjà dans ce dossier.",+ "shellCache.problem.taken": "Le dossier choisi contient déjà un dossier de cache. Choisissez un autre dossier ou déplacez d’abord celui-ci.",+ "shellCache.problem.unknown": "Le dossier de cache contient des fichiers que le lanceur n’a pas créés, il n’est donc pas déplacé.","shellCache.row": "Fichiers de cache",+ "shellCache.sameDrive": "Le nouvel emplacement est sur le même disque. Le dossier est déplacé tout de suite, rien n’est copié.",+ "shellCache.size": "Taille",+ "shellCache.stopped": "Arrêté. Rien n’a changé, le cache reste dans %@.",+ "shellCache.to": "Vers",+ "shellCache.useDefault": "Remettre à l’emplacement par défaut","stage.address_regions": "Régions d’adresses","stage.app_build": "Compilation de l’app","stage.build_id_lookup": "Recherche du build ID",diff --git a/frontend/l10n/it.json b/frontend/l10n/it.jsonindex b8907b36..fd15958b 100644--- a/frontend/l10n/it.json+++ b/frontend/l10n/it.json@@ -1136,9 +1136,40 @@"shell.step3Title": "Invia i dati di gioco","shell.whereDevice": "Dispositivo","shell.whereDrive": "Disco o cartella",+ "shellCache.busy": "È in corso una compilazione o un’installazione. Sposta la cache quando è finita.",+ "shellCache.checking": "Verifica della copia, %@ di %@",+ "shellCache.confirmTitle": "Spostare la cartella della cache?",+ "shellCache.copying": "Copia, %@ di %@",+ "shellCache.fail.ledger": "non è stato possibile aggiornare shell.json",+ "shellCache.fail.mismatch": "la copia di %@ non corrisponde all’originale",+ "shellCache.failed": "Non è stato possibile spostare la cache: %@. Resta in %@ e continua a essere usata.",+ "shellCache.free": "Libero lì",+ "shellCache.from": "Da",+ "shellCache.go": "Sposta",+ "shellCache.move": "Sposta cartella…",+ "shellCache.moved": "La cache ora è in %@.",+ "shellCache.movedOldStays": "La cache ora è in %@. Alcuni file della vecchia cartella non si sono potuti rimuovere. Puoi eliminare %@ nel Finder.",+ "shellCache.movingNote": "La vecchia cartella resta finché la copia non è verificata. Interrompi la lascia com’era.","shellCache.note": "La cache dei framework per iPhone, conservata per poter installare più giochi. Se la elimini, l’installazione di un nuovo gioco rimuove i giochi precedenti dall’app condivisa.",+ "shellCache.nothingYet": "Non c’è ancora una cache. Le nuove installazioni usano la nuova posizione.","shellCache.open": "Apri cartella",+ "shellCache.otherDrive": "La nuova posizione è su un altro disco. I file vengono copiati e verificati, poi la vecchia cartella viene rimossa. Se qualcosa va storto, la vecchia cartella resta e continua a essere usata.",+ "shellCache.pickButton": "Scegli",+ "shellCache.pickMessage": "Scegli dove va la cache. Viene spostata in una nuova cartella dentro la cartella che scegli.",+ "shellCache.problem.inside": "Questa cartella è dentro la cache. Scegline un’altra.",+ "shellCache.problem.ledger": "Il file shell.json della cache non si può leggere, quindi la cartella non viene spostata.",+ "shellCache.problem.noSpace": "Spazio insufficiente sul disco: la cache richiede %@, ne sono liberi %@.",+ "shellCache.problem.notPlain": "La cartella della cache è un collegamento o non è una cartella normale, quindi non viene spostata.",+ "shellCache.problem.readOnly": "Questo disco è di sola lettura. Scegline un altro.",+ "shellCache.problem.same": "La cache è già in questa cartella.",+ "shellCache.problem.taken": "La cartella scelta contiene già una cartella della cache. Scegli un’altra cartella o sposta prima quella.",+ "shellCache.problem.unknown": "La cartella della cache contiene file che il launcher non ha creato, quindi non viene spostata.","shellCache.row": "File della cache",+ "shellCache.sameDrive": "La nuova posizione è sullo stesso disco. La cartella viene spostata subito e non si copia nulla.",+ "shellCache.size": "Dimensione",+ "shellCache.stopped": "Interrotto. Non è cambiato nulla, la cache resta in %@.",+ "shellCache.to": "A",+ "shellCache.useDefault": "Riporta nella posizione predefinita","stage.address_regions": "regioni di indirizzi","stage.app_build": "build dell’app","stage.build_id_lookup": "ricerca del build ID",diff --git a/frontend/l10n/sv.json b/frontend/l10n/sv.jsonindex 1312a647..7f22e5ed 100644--- a/frontend/l10n/sv.json+++ b/frontend/l10n/sv.json@@ -973,9 +973,40 @@"shell.step3Title": "Skicka speldata","shell.whereDevice": "Enhet","shell.whereDrive": "Disk eller mapp",+ "shellCache.busy": "Ett bygge eller en installation pågår. Flytta cachen när det är klart.",+ "shellCache.checking": "Kontrollerar kopian, %@ av %@",+ "shellCache.confirmTitle": "Flytta cachemappen?",+ "shellCache.copying": "Kopierar, %@ av %@",+ "shellCache.fail.ledger": "shell.json kunde inte uppdateras",+ "shellCache.fail.mismatch": "kopian av %@ är inte samma som originalet",+ "shellCache.failed": "Cachen kunde inte flyttas: %@. Den finns kvar i %@ och används som förut.",+ "shellCache.free": "Ledigt där",+ "shellCache.from": "Från",+ "shellCache.go": "Flytta",+ "shellCache.move": "Flytta mapp…",+ "shellCache.moved": "Cachen finns nu i %@.",+ "shellCache.movedOldStays": "Cachen finns nu i %@. Några filer i den gamla mappen kunde inte tas bort. Du kan radera %@ i Finder.",+ "shellCache.movingNote": "Den gamla mappen finns kvar tills kopian är kontrollerad. Stoppa lämnar den som den var.","shellCache.note": "iPhone-framework-cachen, bevarad för installation av flera spel. Raderar du den tar installationen av ett nytt spel bort äldre spel från skalet.",+ "shellCache.nothingYet": "Det finns ingen cache än. Nya installationer använder den nya platsen.","shellCache.open": "Öppna mapp",+ "shellCache.otherDrive": "Den nya platsen är på en annan disk. Filerna kopieras och kontrolleras, sedan tas den gamla mappen bort. Om något går fel finns den gamla mappen kvar och används som förut.",+ "shellCache.pickButton": "Välj",+ "shellCache.pickMessage": "Välj vart cachen ska. Den flyttas till en ny mapp i mappen du väljer.",+ "shellCache.problem.inside": "Den här mappen ligger i cachen. Välj en annan.",+ "shellCache.problem.ledger": "Cachens shell.json kan inte läsas, så mappen flyttas inte.",+ "shellCache.problem.noSpace": "Inte tillräckligt med plats på disken: cachen behöver %@, %@ är ledigt.",+ "shellCache.problem.notPlain": "Cachemappen är en länk eller ingen vanlig mapp, så den flyttas inte.",+ "shellCache.problem.readOnly": "Den här disken är skrivskyddad. Välj en annan.",+ "shellCache.problem.same": "Cachen finns redan i den här mappen.",+ "shellCache.problem.taken": "Den valda mappen har redan en cachemapp. Välj en annan mapp eller flytta bort den först.",+ "shellCache.problem.unknown": "Cachemappen innehåller filer som startprogrammet inte skapade, så den flyttas inte.","shellCache.row": "Cachefiler",+ "shellCache.sameDrive": "Den nya platsen är på samma disk. Mappen flyttas direkt och inget kopieras.",+ "shellCache.size": "Storlek",+ "shellCache.stopped": "Stoppat. Inget ändrades, cachen finns kvar i %@.",+ "shellCache.to": "Till",+ "shellCache.useDefault": "Flytta tillbaka till standardplatsen","stage.address_regions": "Adressområden","stage.app_build": "Bygg appen","stage.build_id_lookup": "Söker bygg-ID",diff --git a/frontend/l10n/zh.json b/frontend/l10n/zh.jsonindex 4884f1c1..a4f8064a 100644--- a/frontend/l10n/zh.json+++ b/frontend/l10n/zh.json@@ -1260,9 +1260,40 @@"shell.step3Title": "发送游戏数据","shell.whereDevice": "设备","shell.whereDrive": "磁盘或文件夹",+ "shellCache.busy": "正在构建或安装。完成后再移动缓存。",+ "shellCache.checking": "正在校验副本,%@ / %@",+ "shellCache.confirmTitle": "移动缓存目录?",+ "shellCache.copying": "正在复制,%@ / %@",+ "shellCache.fail.ledger": "无法更新 shell.json",+ "shellCache.fail.mismatch": "%@ 的副本与原文件不一致",+ "shellCache.failed": "缓存无法移动:%@。缓存仍在 %@,并继续使用。",+ "shellCache.free": "目标可用",+ "shellCache.from": "从",+ "shellCache.go": "移动",+ "shellCache.move": "移动目录…",+ "shellCache.moved": "缓存现在位于 %@。",+ "shellCache.movedOldStays": "缓存现在位于 %@。旧目录中有些文件无法删除,你可以在访达中删除 %@。",+ "shellCache.movingNote": "副本校验完成前,旧目录一直保留。停止后旧目录保持原样。","shellCache.note": "iPhone 端 Framework 缓存,多游戏安装需保留。删除缓存后,安装新游戏,老游戏会消失。",+ "shellCache.nothingYet": "目前还没有缓存。之后的安装会使用新位置。","shellCache.open": "打开目录",+ "shellCache.otherDrive": "新位置在另一个磁盘上。文件会先复制并校验,然后才删除旧目录。任何一步出错,旧目录都会保留并继续使用。",+ "shellCache.pickButton": "选择",+ "shellCache.pickMessage": "选择缓存的新位置。缓存会移到所选目录里的一个新文件夹中。",+ "shellCache.problem.inside": "这个目录在缓存内部。请选择其他目录。",+ "shellCache.problem.ledger": "无法读取缓存中的 shell.json,因此不会移动目录。",+ "shellCache.problem.noSpace": "磁盘空间不足:缓存需要 %@,可用 %@。",+ "shellCache.problem.notPlain": "缓存目录是一个链接或不是普通目录,因此不会移动。",+ "shellCache.problem.readOnly": "这个磁盘是只读的。请选择其他磁盘。",+ "shellCache.problem.same": "缓存已经在这个目录中。",+ "shellCache.problem.taken": "所选目录中已经有一个缓存目录。请选择其他目录,或先把它移走。",+ "shellCache.problem.unknown": "缓存目录中有不是启动器创建的文件,因此不会移动。","shellCache.row": "缓存文件",+ "shellCache.sameDrive": "新位置在同一个磁盘上。目录会直接移动,不复制任何文件。",+ "shellCache.size": "大小",+ "shellCache.stopped": "已停止。没有任何改动,缓存仍在 %@。",+ "shellCache.to": "到",+ "shellCache.useDefault": "移回默认位置","stage.address_regions": "地址区域","stage.app_build": "构建 App","stage.build_id_lookup": "查找构建 ID",