NotesFolder: Add more debug information when loading

This will help better diagnose why files don't sometimes show up
This commit is contained in:
Vishesh Handa
2020-03-08 00:42:19 +01:00
parent 09ff8b2704
commit 9a65686f1e

View File

@ -1,5 +1,6 @@
import 'dart:io';
import 'package:fimber/fimber.dart';
import 'package:path/path.dart' as p;
import 'package:path/path.dart';
@ -161,6 +162,7 @@ class NotesFolder
}
if (fsEntity is Directory) {
Fimber.d("Found directory ${fsEntity.path}");
var subFolder = NotesFolder(this, fsEntity.path);
if (subFolder.name.startsWith('.')) {
continue;
@ -177,8 +179,10 @@ class NotesFolder
var note = Note(this, fsEntity.path);
if (!note.filePath.toLowerCase().endsWith('.md')) {
Fimber.d("Ignoring file ${fsEntity.path}");
continue;
}
Fimber.d("Found file ${fsEntity.path}");
note.addListener(_entityChanged);
_notes.add(note);
@ -198,12 +202,14 @@ class NotesFolder
_entityMap.remove(path);
if (e is Note) {
Fimber.d("File $path was no longer found");
var i = _notes.indexWhere((n) => n.filePath == path);
assert(i != -1);
var note = _notes[i];
_notes.removeAt(i);
notifyNoteRemoved(i, note);
} else {
Fimber.d("Folder $path was no longer found");
var i = _folders.indexWhere((f) => f.folderPath == path);
assert(i != -1);
var folder = _folders[i];