indexImageHash function
Implementation
Future<void> indexImageHash({
required String hash,
required String storedName,
String? scope,
}) async {
try {
await _ensureCollectionDirExists(IMAGE_INDEX_COLLECTION);
final payload = {
'hash': hash,
'storedName': storedName,
'scope': scope ?? '',
'ts': DateTime.now().millisecondsSinceEpoch,
};
// scoped entry
final id = _imageIndexDocId(hash, scope: scope);
await imageIndexCollection.doc(id).set(payload);
// global entry (scope-agnostic fallback)
final globalId = _imageIndexDocId(hash, scope: '');
await imageIndexCollection.doc(globalId).set({
...payload,
'scope': '',
});
} catch (e) {
debugPrint('indexImageHash failed: $e');
}
}