Major update for stability

This commit is contained in:
Mark Gregory
2026-09-08 15:22:19 +01:00
parent 3b95f53a25
commit b2f3c5aef6
24 changed files with 1059 additions and 212 deletions
+16 -2
View File
@@ -5,6 +5,7 @@ import SwiftData
@MainActor
struct RsyncManagerApp: App {
let sharedModelContainer: ModelContainer
let startupStorageError: String?
@StateObject private var runner: RsyncRunner
@StateObject private var automation: BackgroundSyncManager
@@ -14,20 +15,33 @@ struct RsyncManagerApp: App {
SyncRun.self,
])
let configuration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
KeychainStore.delete("defaultSSHPassword")
do {
let container = try ModelContainer(for: schema, configurations: [configuration])
sharedModelContainer = container
startupStorageError = nil
let rsyncRunner = RsyncRunner()
_runner = StateObject(wrappedValue: rsyncRunner)
_automation = StateObject(wrappedValue: BackgroundSyncManager(modelContext: container.mainContext, runner: rsyncRunner))
} catch {
fatalError("Could not create ModelContainer: \(error)")
let fallbackConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: true)
do {
let fallback = try ModelContainer(for: schema, configurations: [fallbackConfiguration])
sharedModelContainer = fallback
startupStorageError = "Rsync Manager could not open its persistent database and is running with temporary in-memory storage for this session. Jobs or history created now will not persist. Original error: \(error.localizedDescription)"
let rsyncRunner = RsyncRunner()
_runner = StateObject(wrappedValue: rsyncRunner)
_automation = StateObject(wrappedValue: BackgroundSyncManager(modelContext: fallback.mainContext, runner: rsyncRunner))
} catch {
fatalError("Rsync Manager could not initialise persistent or temporary storage: \(error)")
}
}
}
var body: some Scene {
WindowGroup {
ContentView()
ContentView(startupStorageError: startupStorageError)
.frame(minWidth: 1040, minHeight: 680)
.environmentObject(runner)
.environmentObject(automation)