[tracker] tracker: Make it superscary to reset databases
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tracker: Make it superscary to reset databases
- Date: Thu, 5 May 2016 11:47:09 +0000 (UTC)
commit ea5479b114306a239e00c9124d6f4125efaa1e3a
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue May 3 03:16:41 2016 +0200
tracker: Make it superscary to reset databases
This is possibly a data loss situation, so warn the user that this is
possibly what will happen.
src/tracker/tracker-color.h | 3 +++
src/tracker/tracker-reset.c | 28 ++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/src/tracker/tracker-color.h b/src/tracker/tracker-color.h
index a297f81..53d7303 100644
--- a/src/tracker/tracker-color.h
+++ b/src/tracker/tracker-color.h
@@ -29,4 +29,7 @@
#define WARN_BEGIN "\033[33m" /* Yellow */
#define WARN_END "\033[0m"
+#define CRIT_BEGIN "\033[1;31m" /* Red */
+#define CRIT_END "\033[0m"
+
#endif /* __TRACKER_COLOR_H__ */
diff --git a/src/tracker/tracker-reset.c b/src/tracker/tracker-reset.c
index 6e67a18..c92389f 100644
--- a/src/tracker/tracker-reset.c
+++ b/src/tracker/tracker-reset.c
@@ -20,6 +20,7 @@
#include "config.h"
#include <stdlib.h>
+#include <stdio.h>
#include <glib.h>
#include <glib/gi18n.h>
@@ -33,6 +34,7 @@
#include "tracker-daemon.h"
#include "tracker-process.h"
#include "tracker-config.h"
+#include "tracker-color.h"
static gboolean hard_reset;
static gboolean soft_reset;
@@ -134,6 +136,32 @@ reset_run (void)
return EXIT_FAILURE;
}
+ if (hard_reset || soft_reset) {
+ gchar response[100] = { 0 };
+
+ g_print (CRIT_BEGIN "%s" CRIT_END "\n%s\n\n%s %s: ",
+ _("CAUTION: This process may irreversibly delete data."),
+ _("Although most content indexed by Tracker can "
+ "be safely reindexed, it can't be assured that "
+ "this is the case for all data. Be aware that "
+ "you may be incurring in a data loss situation, "
+ "proceed at your own risk."),
+ _("Are you sure you want to proceed?"),
+ /* TRANSLATORS: This is to be displayed on command line output */
+ _("[y|N]"));
+
+ fgets (response, 100, stdin);
+ response[strlen (response) - 1] = '\0';
+
+ /* TRANSLATORS: this is our test for a [y|N] question in the command line.
+ * A partial or full match will be considered an affirmative answer,
+ * it is intentionally lowercase, so please keep it like this.
+ */
+ if (!response[0] || !g_str_has_prefix (_("yes"), response)) {
+ return EXIT_FAILURE;
+ }
+ }
+
/* KILL processes first... */
if (hard_reset || soft_reset) {
tracker_process_stop (TRACKER_PROCESS_TYPE_NONE, TRACKER_PROCESS_TYPE_ALL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]