debug option to delete vectorDB index
This commit is contained in:
@@ -279,17 +279,23 @@ class ClipVectorDB {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteIndexFile() async {
|
||||
Future<void> deleteIndexFile({bool undoMigration = false}) async {
|
||||
try {
|
||||
final documentsDirectory = await getApplicationDocumentsDirectory();
|
||||
final String dbPath =
|
||||
join(documentsDirectory.path, _databaseName);
|
||||
final String dbPath = join(documentsDirectory.path, _databaseName);
|
||||
_logger.info("Delete index file: DB path " + dbPath);
|
||||
final file = File(dbPath);
|
||||
if (await file.exists()) {
|
||||
await file.delete();
|
||||
}
|
||||
_logger.info("Deleted index file on disk");
|
||||
_vectorDbFuture = null;
|
||||
if (undoMigration) {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool(_kMigrationKey, false);
|
||||
_migrationDone = false;
|
||||
_logger.info("Undid migration flag");
|
||||
}
|
||||
} catch (e, s) {
|
||||
_logger.severe("Error deleting index file on disk", e, s);
|
||||
rethrow;
|
||||
|
||||
@@ -83,6 +83,24 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
|
||||
logger.info("Building ML Debug section options");
|
||||
return Column(
|
||||
children: [
|
||||
sectionOptionSpacing,
|
||||
MenuItemWidget(
|
||||
captionedTextWidget: const CaptionedTextWidget(
|
||||
title: "Clear vectorDB index",
|
||||
),
|
||||
pressedColor: getEnteColorScheme(context).fillFaint,
|
||||
trailingIcon: Icons.chevron_right_outlined,
|
||||
trailingIconIsMuted: true,
|
||||
onTap: () async {
|
||||
try {
|
||||
await ClipVectorDB.instance.deleteIndexFile(undoMigration: true);
|
||||
showShortToast(context, 'Deleted vectorDB index');
|
||||
} catch (e, s) {
|
||||
logger.severe('vectorDB index delete failed ', e, s);
|
||||
await showGenericErrorDialog(context: context, error: e);
|
||||
}
|
||||
},
|
||||
),
|
||||
sectionOptionSpacing,
|
||||
MenuItemWidget(
|
||||
captionedTextWidget: const CaptionedTextWidget(
|
||||
|
||||
Reference in New Issue
Block a user