Skip to content

Commit 93eb2fe

Browse files
committed
ui: tell the user that migration is going on
1 parent 0b4bc24 commit 93eb2fe

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

Localizable.xcstrings

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19520,6 +19520,40 @@
1952019520
}
1952119521
}
1952219522
},
19523+
"Upgrading the database. This may take a few minutes, depending on how many files you have. Please do not close the app until this is finished." : {
19524+
"localizations" : {
19525+
"de" : {
19526+
"stringUnit" : {
19527+
"state" : "translated",
19528+
"value" : "Die Datenbank wird aktualisiert. Dies kann einige Minuten dauern, je nach der Anzahl der Dateien, die Sie haben. Bitte schließen Sie die App nicht, bis dieser Vorgang abgeschlossen ist."
19529+
}
19530+
},
19531+
"es" : {
19532+
"stringUnit" : {
19533+
"state" : "translated",
19534+
"value" : "Actualizando la base de datos. Esto puede tardar unos minutos, dependiendo de cuántos archivos tengas. Por favor, no cierres la app hasta que esto termine."
19535+
}
19536+
},
19537+
"it" : {
19538+
"stringUnit" : {
19539+
"state" : "translated",
19540+
"value" : "Aggiornamento del database. Questo potrebbe richiedere alcuni minuti, a seconda del numero di file che hai. Si prega di non chiudere l'app finché non è terminato."
19541+
}
19542+
},
19543+
"nl" : {
19544+
"stringUnit" : {
19545+
"state" : "translated",
19546+
"value" : "De database wordt bijgewerkt. Dit kan enkele minuten duren, afhankelijk van hoeveel bestanden je hebt. Sluit de app niet totdat dit is voltooid."
19547+
}
19548+
},
19549+
"uk" : {
19550+
"stringUnit" : {
19551+
"state" : "translated",
19552+
"value" : "Оновлення бази даних. Це може зайняти кілька хвилин, залежно від кількості ваших файлів. Будь ласка, не закривайте програму, доки оновлення не завершиться."
19553+
}
19554+
}
19555+
}
19556+
},
1952319557
"Uptime" : {
1952419558
"localizations" : {
1952519559
"de" : {

Sushitrain/AppState.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ enum AppStartupState: Equatable {
6161
@Published var isLogging: Bool = false
6262
@Published var foldersWithExtraFiles: [String] = []
6363
@Published var startupState: AppStartupState = .notStarted
64+
@Published var isMigratedToNewDatabase: Bool = false
6465

6566
#if os(iOS)
6667
@Published var currentAction: QuickAction? = nil
@@ -152,6 +153,7 @@ enum AppStartupState: Equatable {
152153
}
153154

154155
self.performMigrations()
156+
self.isMigratedToNewDatabase = !client.hasOldDatabase()
155157

156158
let client = self.client
157159
DispatchQueue.global(qos: .userInitiated).async {
@@ -162,6 +164,8 @@ enum AppStartupState: Equatable {
162164
Log.info("Client started")
163165

164166
DispatchQueue.main.async {
167+
// Check to see if we have migrated
168+
self.isMigratedToNewDatabase = !client.hasOldDatabase()
165169
Log.info("Configuring the user interface...")
166170
self.applySettings()
167171
self.update()

Sushitrain/ContentView.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ struct MainView: View {
1414
var body: some View {
1515
switch appState.startupState {
1616
case .notStarted:
17-
ProgressView().progressViewStyle(.circular)
17+
VStack(spacing: 10) {
18+
ProgressView().progressViewStyle(.circular)
19+
if !appState.isMigratedToNewDatabase {
20+
// We are likely migrating now
21+
Text("Upgrading the database. This may take a few minutes, depending on how many files you have. Please do not close the app until this is finished.")
22+
.foregroundStyle(.secondary)
23+
.multilineTextAlignment(.center)
24+
.frame(maxWidth: 320)
25+
}
26+
}
1827
case .error(let e):
1928
ContentUnavailableView("Cannot start the app", systemImage: "exclamationmark.triangle.fill", description: Text(e))
2029
case .started:

SushitrainCore/src/sushitrain.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,14 @@ func (clt *Client) IsDownloading() bool {
475475
return false
476476
}
477477

478+
func (clt *Client) HasOldDatabase() bool {
479+
if _, err := os.Lstat(locations.Get(locations.LegacyDatabase)); err != nil {
480+
// No old database
481+
return false
482+
}
483+
return true
484+
}
485+
478486
// This method loads and migrates the Syncthing database, then starts up an instance. It also starts the streaming web
479487
// server. This method can take a while to complete and should only ever be called once.
480488
func (clt *Client) Start() error {

0 commit comments

Comments
 (0)