[epiphany/gnome-3-22] history-service: Actually delete database when clearing history
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-3-22] history-service: Actually delete database when clearing history
- Date: Sun, 6 Nov 2016 19:30:59 +0000 (UTC)
commit 226eca83d5cce5035f02c628cc7c9b1526e71fb1
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Nov 6 13:29:02 2016 -0600
history-service: Actually delete database when clearing history
Previously, deleting your history didn't even cause the size of the
history database to shrink on disk. There's only one proper way to
delete an SQLite database, and that's to remove it from the filesystem.
lib/history/ephy-history-service.c | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index e90239f..44b2d3a 100644
--- a/lib/history/ephy-history-service.c
+++ b/lib/history/ephy-history-service.c
@@ -23,6 +23,10 @@
#include "ephy-history-type-builtins.h"
#include "ephy-sqlite-connection.h"
+#include <errno.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+
typedef gboolean (*EphyHistoryServiceMethod) (EphyHistoryService *self, gpointer data, gpointer
*result);
typedef enum {
@@ -411,20 +415,25 @@ ephy_history_service_close_database_connections (EphyHistoryService *self)
static void
ephy_history_service_clear_all (EphyHistoryService *self)
{
- GError *error = NULL;
+ char *journal_filename;
- if (NULL == self->history_database)
+ if (self->history_database == NULL)
return;
if (self->read_only)
return;
- ephy_sqlite_connection_execute (self->history_database,
- "DELETE FROM hosts;", &error);
- if (error) {
- g_warning ("Couldn't clear history database: %s", error->message);
- g_error_free (error);
- }
+ ephy_sqlite_connection_close (self->history_database);
+
+ if (g_unlink (self->history_filename) == -1)
+ g_warning ("Failed to delete %s: %s", self->history_filename, g_strerror (errno));
+
+ journal_filename = g_strdup_printf ("%s-journal", self->history_filename);
+ if (g_unlink (journal_filename) == -1 && errno != ENOENT)
+ g_warning ("Failed to delete %s: %s", journal_filename, g_strerror (errno));
+ g_free (journal_filename);
+
+ ephy_history_service_open_database_connections (self);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]