mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 01:45:55 +08:00
Move building the repo's path logic to one place
Instead of having it duplicated
This commit is contained in:
@ -69,7 +69,7 @@ class JournalApp extends StatefulWidget {
|
||||
|
||||
await settings.migrate(pref, appState.gitBaseDirectory);
|
||||
|
||||
var gitRepoDir = p.join(appState.gitBaseDirectory, settings.folderName);
|
||||
var gitRepoDir = settings.buildRepoPath(appState.gitBaseDirectory);
|
||||
|
||||
var repoDirStat = File(gitRepoDir).statSync();
|
||||
if (repoDirStat.type != FileSystemEntityType.directory) {
|
||||
|
@ -333,6 +333,12 @@ class Settings extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String buildRepoPath(String internalDir) {
|
||||
return storeInternally
|
||||
? p.join(internalDir, folderName)
|
||||
: p.join(storageLocation, folderName);
|
||||
}
|
||||
}
|
||||
|
||||
class NoteFileNameFormat {
|
||||
|
@ -43,10 +43,7 @@ class StateContainer with ChangeNotifier {
|
||||
@required this.gitBaseDirectory,
|
||||
@required this.cacheDirectory,
|
||||
}) {
|
||||
var folderName = settings.folderName;
|
||||
repoPath = settings.storeInternally
|
||||
? p.join(gitBaseDirectory, folderName)
|
||||
: p.join(settings.storageLocation, folderName);
|
||||
repoPath = settings.buildRepoPath(appState.gitBaseDirectory);
|
||||
|
||||
_gitRepo = GitNoteRepository(gitDirPath: repoPath, settings: settings);
|
||||
appState.notesFolder = NotesFolderFS(null, _gitRepo.gitDirPath, settings);
|
||||
@ -358,10 +355,7 @@ class StateContainer with ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> moveRepoToPath() async {
|
||||
var folderName = settings.folderName;
|
||||
var newRepoPath = settings.storeInternally
|
||||
? p.join(gitBaseDirectory, folderName)
|
||||
: p.join(settings.storageLocation, folderName);
|
||||
var newRepoPath = settings.buildRepoPath(appState.gitBaseDirectory);
|
||||
|
||||
if (newRepoPath != repoPath) {
|
||||
Log.i("Old Path: $repoPath");
|
||||
|
Reference in New Issue
Block a user