mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +08:00
Immediately save the note when changing
Earlier we would wait till we got the 'mutex' to make a change, however with the way libgit2 works, during a git push/pull other git operations such as add/rm/commit block. So performing a save, while the push/pull is occuring - might have resulted in a note being lost Related to #124
This commit is contained in:
@ -36,7 +36,6 @@ class GitNoteRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<NoteRepoResult> _addNote(Note note, String commitMessage) async {
|
Future<NoteRepoResult> _addNote(Note note, String commitMessage) async {
|
||||||
await note.save();
|
|
||||||
await _gitRepo.add(".");
|
await _gitRepo.add(".");
|
||||||
await _gitRepo.commit(
|
await _gitRepo.commit(
|
||||||
message: commitMessage,
|
message: commitMessage,
|
||||||
|
@ -259,11 +259,13 @@ class StateContainer with ChangeNotifier {
|
|||||||
void addNote(Note note) async {
|
void addNote(Note note) async {
|
||||||
logEvent(Event.NoteAdded);
|
logEvent(Event.NoteAdded);
|
||||||
|
|
||||||
|
note.parent.add(note);
|
||||||
|
note.updateModified();
|
||||||
|
await note.save();
|
||||||
|
|
||||||
return _opLock.synchronized(() async {
|
return _opLock.synchronized(() async {
|
||||||
Log.d("Got addNote lock");
|
Log.d("Got addNote lock");
|
||||||
|
|
||||||
note.parent.add(note);
|
|
||||||
note.updateModified();
|
|
||||||
_gitRepo.addNote(note).then((NoteRepoResult _) {
|
_gitRepo.addNote(note).then((NoteRepoResult _) {
|
||||||
_syncNotes();
|
_syncNotes();
|
||||||
appState.numChanges += 1;
|
appState.numChanges += 1;
|
||||||
@ -311,10 +313,12 @@ class StateContainer with ChangeNotifier {
|
|||||||
void updateNote(Note note) async {
|
void updateNote(Note note) async {
|
||||||
logEvent(Event.NoteUpdated);
|
logEvent(Event.NoteUpdated);
|
||||||
|
|
||||||
|
note.updateModified();
|
||||||
|
await note.save();
|
||||||
|
|
||||||
return _opLock.synchronized(() async {
|
return _opLock.synchronized(() async {
|
||||||
Log.d("Got updateNote lock");
|
Log.d("Got updateNote lock");
|
||||||
|
|
||||||
note.updateModified();
|
|
||||||
_gitRepo.updateNote(note).then((NoteRepoResult _) {
|
_gitRepo.updateNote(note).then((NoteRepoResult _) {
|
||||||
_syncNotes();
|
_syncNotes();
|
||||||
appState.numChanges += 1;
|
appState.numChanges += 1;
|
||||||
|
Reference in New Issue
Block a user