From 42d755be1d3333a374b53274236eb75718c8d265 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Tue, 21 Jul 2020 11:19:27 +0200 Subject: [PATCH] Make sure local git repo always exists There are some cases when upgrading from a really old version that the journal_local no longer exists. --- lib/app.dart | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/app.dart b/lib/app.dart index 8047dc58..3785b671 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -71,7 +71,21 @@ class JournalApp extends StatefulWidget { Log.i("New Documents Directory Path ${dir.path}"); } - if (appState.localGitRepoConfigured == false) { + // Handle migrations - Remove this code in 2021 + var localConfigured = appState.localGitRepoConfigured; + if (localConfigured && appState.remoteGitRepoConfigured == false) { + appState.localGitRepoFolderName = "journal_local"; + var repoPath = p.join( + appState.gitBaseDirectory, + appState.localGitRepoFolderName, + ); + + if (!Directory(repoPath).existsSync()) { + localConfigured = false; + } + } + + if (localConfigured == false) { // FIXME: What about exceptions! appState.localGitRepoFolderName = "journal_local"; var repoPath = p.join(