mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-26 16:46:51 +08:00
Try to fix concurrent modification error
This commit is contained in:
@ -63,17 +63,21 @@ class NotesFolderFS with NotesFolderNotifier implements NotesFolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _noteRenamed(Note note, String oldPath) {
|
void _noteRenamed(Note note, String oldPath) {
|
||||||
assert(_entityMap.containsKey(oldPath));
|
_lock.synchronized(() {
|
||||||
_entityMap.remove(oldPath);
|
assert(_entityMap.containsKey(oldPath));
|
||||||
_entityMap[note.filePath] = note;
|
_entityMap.remove(oldPath);
|
||||||
|
_entityMap[note.filePath] = note;
|
||||||
|
|
||||||
notifyNoteRenamed(-1, note, oldPath);
|
notifyNoteRenamed(-1, note, oldPath);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _subFolderRenamed(NotesFolderFS folder, String oldPath) {
|
void _subFolderRenamed(NotesFolderFS folder, String oldPath) {
|
||||||
assert(_entityMap.containsKey(oldPath));
|
_lock.synchronized(() {
|
||||||
_entityMap.remove(oldPath);
|
assert(_entityMap.containsKey(oldPath));
|
||||||
_entityMap[folder.folderPath] = folder;
|
_entityMap.remove(oldPath);
|
||||||
|
_entityMap[folder.folderPath] = folder;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset(String folderPath) {
|
void reset(String folderPath) {
|
||||||
@ -168,18 +172,20 @@ class NotesFolderFS with NotesFolderNotifier implements NotesFolder {
|
|||||||
futures = <Future>[];
|
futures = <Future>[];
|
||||||
|
|
||||||
// Remove notes which have errors
|
// Remove notes which have errors
|
||||||
var errFunc = (Note n) => n.loadState == NoteLoadState.Error;
|
await _lock.synchronized(() {
|
||||||
var hasBadNotes = _notes.any(errFunc);
|
var errFunc = (Note n) => n.loadState == NoteLoadState.Error;
|
||||||
if (hasBadNotes) {
|
var hasBadNotes = _notes.any(errFunc);
|
||||||
while (true) {
|
if (hasBadNotes) {
|
||||||
var i = _notes.indexWhere(errFunc);
|
while (true) {
|
||||||
if (i == -1) {
|
var i = _notes.indexWhere(errFunc);
|
||||||
break;
|
if (i == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var note = _notes.removeAt(i);
|
||||||
|
notifyNoteRemoved(i, note);
|
||||||
}
|
}
|
||||||
var note = _notes.removeAt(i);
|
|
||||||
notifyNoteRemoved(i, note);
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
for (var folder in _folders) {
|
for (var folder in _folders) {
|
||||||
var f = folder.loadRecursively();
|
var f = folder.loadRecursively();
|
||||||
|
Reference in New Issue
Block a user