From 9cb810f41d5ce3917df938f4b9c563924e4eaace Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Tue, 9 Jun 2020 17:44:04 +0200 Subject: [PATCH] Handle case where documents path changes It seems sometimes when an app is updated their documents path changes. So our cached version of it is now incorrect and needs to be refreshed - Fixes #159 --- lib/app.dart | 8 ++++++++ lib/appstate.dart | 1 + 2 files changed, 9 insertions(+) diff --git a/lib/app.dart b/lib/app.dart index f608a20a..673c8eab 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -59,6 +59,14 @@ class JournalApp extends StatefulWidget { appState.save(pref); } + if (!Directory(appState.gitBaseDirectory).existsSync()) { + Log.w("Applications Documents Directory no longer exists"); + var dir = await getApplicationDocumentsDirectory(); + appState.gitBaseDirectory = dir.path; + appState.save(pref); + Log.i("New Documents Directory Path ${dir.path}"); + } + if (appState.localGitRepoConfigured == false) { // FIXME: What about exceptions! appState.localGitRepoFolderName = "journal_local"; diff --git a/lib/appstate.dart b/lib/appstate.dart index 68df6429..228c5499 100644 --- a/lib/appstate.dart +++ b/lib/appstate.dart @@ -55,6 +55,7 @@ class AppState { Log.i("localGitRepoFolderName: $localGitRepoFolderName"); Log.i("remoteGitRepoFolderName: $remoteGitRepoFolderName"); Log.i("onBoardingCompleted: $onBoardingCompleted"); + Log.i("gitBaseDirectory: $gitBaseDirectory"); Log.i(" ------------------ "); }