π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix: move the concat logic to sql side
Prateek Sunal4419090831c8
diff --git a/mobile/lib/db/entities_db.dart b/mobile/lib/db/entities_db.dartindex 3cd9d47639..052da4e29b 100644--- a/mobile/lib/db/entities_db.dart+++ b/mobile/lib/db/entities_db.dart@@ -99,4 +99,19 @@ extension EntitiesDB on FilesDB {}return LocalEntityData.fromJson(maps.first);}++ Future<String?> getUpdatedAtHash(+ EntityType type,+ List<String> ids,+ ) async {+ final db = await sqliteAsyncDB;+ final maps = await db.get(+ 'SELECT GROUP_CONCAT(id || \':\' || updatedAt, \',\') FROM entities WHERE type = ? AND id IN (${List.filled(ids.length, '?').join(',')})',+ [type.name, ...ids],+ );+ if (maps.isEmpty) {+ return null;+ }+ return maps.values.first as String?;+ }}diff --git a/mobile/lib/services/entity_service.dart b/mobile/lib/services/entity_service.dartindex 213fb07217..509d0ed3a7 100644--- a/mobile/lib/services/entity_service.dart+++ b/mobile/lib/services/entity_service.dart@@ -221,20 +221,20 @@ class EntityService {}}- Future<String> getHashForIds(List<String> personIds) async {- String preHash = "";-- for (final id in personIds) {- final entity = await getEntity(EntityType.cgroup, id);+ Future<String?> getUpdatedAtHash(+ EntityType type,+ List<String> ids,+ ) async {+ return await _db.getUpdatedAtHash(type, ids);+ }- if (entity != null) {- preHash = "$id:${entity.updatedAt}_";- }- }+ Future<String> getHashForIds(List<String> personIds) async {+ final preHash = await getUpdatedAtHash(EntityType.cgroup, personIds);- if (preHash.isEmpty) {+ if (preHash == null) {return "";}+final hash = md5.convert(utf8.encode(preHash)).toString().substring(0, 10);return hash;}