getDocument method
Implementation
Future<File?> getDocument(String docPath, {String? scope}) async {
final filename = docPath.split('/').last;
final s = (scope ?? '').trim();
final legacyScope =
s.contains('undefined') ? s.replaceAll('undefined', 'null') : s;
final candidates = <String>[
if (s.isNotEmpty) '$s/Dokus/$filename',
if (legacyScope.isNotEmpty && legacyScope != s)
'$legacyScope/Dokus/$filename',
// legacy: flat storage
filename,
];
for (final name in candidates) {
final doc = await readDoc(name);
if (doc != null) return doc;
}
throw Exception("no doc cached");
}