Skip to content

armgit / ente

Public Imported from GitHub
0

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

delete table option

laurenspriem2f5a02ec430b
diff --git a/mobile/lib/db/ml/clip_vector_db.dart b/mobile/lib/db/ml/clip_vector_db.dart
index eb28181d3c..84d3261460 100644
--- a/mobile/lib/db/ml/clip_vector_db.dart
+++ b/mobile/lib/db/ml/clip_vector_db.dart
@@ -111,6 +111,17 @@ class ClipVectorDB {
}
}
+ Future<void> deleteIndex() async {
+ final db = await _vectorDB;
+ try {
+ await db.deleteIndex();
+ _vectorDbFuture = null;
+ } catch (e, s) {
+ _logger.severe("Error deleting index", e, s);
+ rethrow;
+ }
+ }
+
Future<(int, int, int)> getIndexStats() async {
final db = await _vectorDB;
try {
diff --git a/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart b/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart
index 117f706735..c2c3406bc5 100644
--- a/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart
+++ b/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart
@@ -211,7 +211,7 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
sectionOptionSpacing,
MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget(
- title: "Empty ClipVectorDB",
+ title: "Delete/Empty ClipVectorDB",
),
pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined,
@@ -219,22 +219,7 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
onTap: () async {
try {
final clipVectorDB = ClipVectorDB.instance;
- final stats = await clipVectorDB.getIndexStats();
- logger.info("ClipVectorDB stats: size: ${stats.$1}, "
- "capacity: ${stats.$2}, dimensions: ${stats.$3}");
- showShortToast(
- context,
- "ClipVectorDB stats: size: ${stats.$1}, "
- "capacity: ${stats.$2}, dimensions: ${stats.$3}");
-
- await clipVectorDB.deleteAllEmbeddings();
- final statsAfter = await clipVectorDB.getIndexStats();
- logger.info("ClipVectorDB stats after: size: ${statsAfter.$1}, "
- "capacity: ${statsAfter.$2}, dimensions: ${statsAfter.$3}");
- showShortToast(
- context,
- "ClipVectorDB stats after: size: ${statsAfter.$1}, "
- "capacity: ${statsAfter.$2}, dimensions: ${statsAfter.$3}");
+ await clipVectorDB.deleteIndex();
} catch (e, s) {
logger.warning('ClipVectorDB cleanup failed ', e, s);
await showGenericErrorDialog(context: context, error: e);