mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 18:03:14 +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);
|
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();
|
var repoDirStat = File(gitRepoDir).statSync();
|
||||||
if (repoDirStat.type != FileSystemEntityType.directory) {
|
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 {
|
class NoteFileNameFormat {
|
||||||
|
@ -43,10 +43,7 @@ class StateContainer with ChangeNotifier {
|
|||||||
@required this.gitBaseDirectory,
|
@required this.gitBaseDirectory,
|
||||||
@required this.cacheDirectory,
|
@required this.cacheDirectory,
|
||||||
}) {
|
}) {
|
||||||
var folderName = settings.folderName;
|
repoPath = settings.buildRepoPath(appState.gitBaseDirectory);
|
||||||
repoPath = settings.storeInternally
|
|
||||||
? p.join(gitBaseDirectory, folderName)
|
|
||||||
: p.join(settings.storageLocation, folderName);
|
|
||||||
|
|
||||||
_gitRepo = GitNoteRepository(gitDirPath: repoPath, settings: settings);
|
_gitRepo = GitNoteRepository(gitDirPath: repoPath, settings: settings);
|
||||||
appState.notesFolder = NotesFolderFS(null, _gitRepo.gitDirPath, settings);
|
appState.notesFolder = NotesFolderFS(null, _gitRepo.gitDirPath, settings);
|
||||||
@ -358,10 +355,7 @@ class StateContainer with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> moveRepoToPath() async {
|
Future<void> moveRepoToPath() async {
|
||||||
var folderName = settings.folderName;
|
var newRepoPath = settings.buildRepoPath(appState.gitBaseDirectory);
|
||||||
var newRepoPath = settings.storeInternally
|
|
||||||
? p.join(gitBaseDirectory, folderName)
|
|
||||||
: p.join(settings.storageLocation, folderName);
|
|
||||||
|
|
||||||
if (newRepoPath != repoPath) {
|
if (newRepoPath != repoPath) {
|
||||||
Log.i("Old Path: $repoPath");
|
Log.i("Old Path: $repoPath");
|
||||||
|
Reference in New Issue
Block a user