Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob] Fix reset queries for feedback & clusters

Neeraj Gupta8e322114b753
diff --git a/mobile/lib/face/db.dart b/mobile/lib/face/db.dart
index f2a8dd931d..e3b2d56c5c 100644
--- a/mobile/lib/face/db.dart
+++ b/mobile/lib/face/db.dart
@@ -444,9 +444,9 @@ class FaceMLDataDB {
Future<void> resetClusterIDs() async {
final db = await instance.database;
- await db.rawQuery(dropFaceClustersTable);
- await db.rawQuery(createFaceClustersTable);
- await db.rawQuery(fcClusterIDIndex);
+ await db.execute(dropFaceClustersTable);
+ await db.execute(createFaceClustersTable);
+ await db.execute(fcClusterIDIndex);
}
Future<void> insert(Person p, int cluserID) async {
@@ -647,6 +647,7 @@ class FaceMLDataDB {
await db.execute(createFacesTable);
await db.execute(dropFaceClustersTable);
await db.execute(createFaceClustersTable);
+ await db.execute(fcClusterIDIndex);
}
await db.execute(deletePersonTable);
await db.execute(dropClusterPersonTable);
diff --git a/mobile/lib/face/db_fields.dart b/mobile/lib/face/db_fields.dart
index ba21046aaf..379845f083 100644
--- a/mobile/lib/face/db_fields.dart
+++ b/mobile/lib/face/db_fields.dart
@@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS $faceClustersTable (
''';
// -- Creating a non-unique index on clusterID for query optimization
const fcClusterIDIndex =
- '''CREATE INDEX IF NOT EXISTS idx_fcClusterID ON faceClustersTable(fcClusterID);''';
+ '''CREATE INDEX IF NOT EXISTS idx_fcClusterID ON $faceClustersTable($fcClusterID);''';
const dropFaceClustersTable = 'DROP TABLE IF EXISTS $faceClustersTable';
//##endregion
diff --git a/mobile/lib/ui/settings/debug/face_debug_section_widget.dart b/mobile/lib/ui/settings/debug/face_debug_section_widget.dart
index dd0561fc03..5a76320c32 100644
--- a/mobile/lib/ui/settings/debug/face_debug_section_widget.dart
+++ b/mobile/lib/ui/settings/debug/face_debug_section_widget.dart
@@ -181,7 +181,7 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
sectionOptionSpacing,
MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget(
- title: "Reset feedback & labels",
+ title: "Reset feedback & clusters",
),
pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined,
@@ -194,10 +194,15 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
"You will need to again cluster all the faces. You can drop feedback if you want to return to original cluster labels",
firstButtonLabel: "Yes, confirm",
firstButtonOnTap: () async {
- await FaceMLDataDB.instance.resetClusterIDs();
- await FaceMLDataDB.instance.dropClustersAndPersonTable();
- Bus.instance.fire(PeopleChangedEvent());
- showShortToast(context, "Done");
+ try {
+ await FaceMLDataDB.instance.resetClusterIDs();
+ await FaceMLDataDB.instance.dropClustersAndPersonTable();
+ Bus.instance.fire(PeopleChangedEvent());
+ showShortToast(context, "Done");
+ } catch (e, s) {
+ _logger.warning('reset feedback failed ', e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
},
);
},