diff --git a/lib/app.dart b/lib/app.dart index c7077a9a..83972fcc 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -83,6 +83,7 @@ class JournalApp extends StatefulWidget { settings.localGitRepoConfigured = true; settings.save(); } + final cacheDir = await getApplicationSupportDirectory(); Widget app = ChangeNotifierProvider.value( value: settings, @@ -92,6 +93,7 @@ class JournalApp extends StatefulWidget { appState: appState, settings: settings, gitBaseDirectory: appState.gitBaseDirectory, + cacheDirectory: cacheDir.path, ); }, child: ChangeNotifierProvider( diff --git a/lib/settings.dart b/lib/settings.dart index c1231123..57545ef7 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -320,6 +320,9 @@ class Settings extends ChangeNotifier { Future migrate(SharedPreferences pref, String gitBaseDir) async { if (version == 0) { + var cache = p.join(gitBaseDir, "cache.json"); + await File(cache).delete(recursive: true); + if (localGitRepoConfigured && !remoteGitRepoConfigured) { Log.i("Migrating from local and remote repos to a single one"); var oldName = p.join(gitBaseDir, "journal_local"); diff --git a/lib/state_container.dart b/lib/state_container.dart index 29c100c8..b9b4faae 100644 --- a/lib/state_container.dart +++ b/lib/state_container.dart @@ -24,6 +24,7 @@ class StateContainer with ChangeNotifier { final AppState appState; final Settings settings; final String gitBaseDirectory; + final String cacheDirectory; final _opLock = Lock(); final _loadLock = Lock(); @@ -38,6 +39,7 @@ class StateContainer with ChangeNotifier { @required this.appState, @required this.settings, @required this.gitBaseDirectory, + @required this.cacheDirectory, }) { assert(settings.localGitRepoConfigured); var repoPath = p.join(gitBaseDirectory, settings.internalRepoFolderName); @@ -51,7 +53,7 @@ class StateContainer with ChangeNotifier { value: settings.remoteGitRepoConfigured.toString(), ); - var cachePath = p.join(gitBaseDirectory, "cache.json"); + var cachePath = p.join(cacheDirectory, "cache.json"); _notesCache = NotesCache( filePath: cachePath, notesBasePath: _gitRepo.gitDirPath,