[epiphany/wip/google-safe-browsing: 29/30] gsb-storage: Remove unused timestamp column



commit 32d9c386492472c4c73015df700e45ab397702da
Author: Gabriel Ivascu <gabrielivascu gnome org>
Date:   Fri Sep 22 19:58:41 2017 +0300

    gsb-storage: Remove unused timestamp column

 lib/safe-browsing/ephy-gsb-service.c |    9 ++++-----
 lib/safe-browsing/ephy-gsb-storage.c |   17 +++++------------
 lib/safe-browsing/ephy-gsb-utils.c   |    4 +---
 lib/safe-browsing/ephy-gsb-utils.h   |   12 +++++-------
 4 files changed, 15 insertions(+), 27 deletions(-)
---
diff --git a/lib/safe-browsing/ephy-gsb-service.c b/lib/safe-browsing/ephy-gsb-service.c
index e88516e..24543b7 100644
--- a/lib/safe-browsing/ephy-gsb-service.c
+++ b/lib/safe-browsing/ephy-gsb-service.c
@@ -267,8 +267,7 @@ ephy_gsb_service_update_thread (GTask          *task,
     list = ephy_gsb_threat_list_new (json_object_get_string_member (lur, "threatType"),
                                      json_object_get_string_member (lur, "platformType"),
                                      json_object_get_string_member (lur, "threatEntryType"),
-                                     json_object_get_string_member (lur, "newClientState"),
-                                     CURRENT_TIME);
+                                     json_object_get_string_member (lur, "newClientState"));
     LOG ("Updating list %s/%s/%s", list->threat_type, list->platform_type, list->threat_entry_type);
 
     /* If full update, clear all previous hash prefixes for the given list. */
@@ -576,7 +575,7 @@ ephy_gsb_service_find_full_hashes_cb (SoupSession *session,
     guint8 *hash;
     gsize length;
 
-    list = ephy_gsb_threat_list_new (threat_type, platform_type, threat_entry_type, NULL, 0);
+    list = ephy_gsb_threat_list_new (threat_type, platform_type, threat_entry_type, NULL);
     hash = g_base64_decode (hash_b64, &length);
     positive_duration = json_object_get_string_member (match, "cacheDuration");
     sscanf (positive_duration, "%lfs", &duration);
@@ -610,7 +609,7 @@ ephy_gsb_service_find_full_hashes_cb (SoupSession *session,
       list = ephy_gsb_threat_list_new (lookup->threat_type,
                                        lookup->platform_type,
                                        lookup->threat_entry_type,
-                                       NULL, 0);
+                                       NULL);
       g_hash_table_add (data->threats, list);
     }
   }
@@ -757,7 +756,7 @@ ephy_gsb_service_verify_hashes (EphyGSBService                  *self,
       list = ephy_gsb_threat_list_new (lookup->threat_type,
                                        lookup->platform_type,
                                        lookup->threat_entry_type,
-                                       NULL, 0);
+                                       NULL);
       g_hash_table_add (threats, list);
     }
   }
diff --git a/lib/safe-browsing/ephy-gsb-storage.c b/lib/safe-browsing/ephy-gsb-storage.c
index 9be0798..32edf40 100644
--- a/lib/safe-browsing/ephy-gsb-storage.c
+++ b/lib/safe-browsing/ephy-gsb-storage.c
@@ -226,7 +226,6 @@ ephy_gsb_storage_init_threats_table (EphyGSBStorage *self)
         "platform_type VARCHAR NOT NULL,"
         "threat_entry_type VARCHAR NOT NULL,"
         "client_state VARCHAR,"
-        "timestamp INTEGER NOT NULL DEFAULT (CAST(strftime('%s', 'now') AS INT)),"
         "PRIMARY KEY (threat_type, platform_type, threat_entry_type)"
         ")";
   ephy_sqlite_connection_execute (self->db, sql, &error);
@@ -256,7 +255,7 @@ ephy_gsb_storage_init_threats_table (EphyGSBStorage *self)
     EphyGSBThreatList *list = ephy_gsb_threat_list_new (gsb_linux_threat_lists[i][0],
                                                         gsb_linux_threat_lists[i][1],
                                                         gsb_linux_threat_lists[i][2],
-                                                        NULL, 0);
+                                                        NULL);
     bind_threat_list_params (statement, list, i * 3, i * 3 + 1, i * 3 + 2, -1);
     ephy_gsb_threat_list_free (list);
   }
@@ -291,7 +290,6 @@ ephy_gsb_storage_init_hash_prefix_table (EphyGSBStorage *self)
         "threat_type VARCHAR NOT NULL,"
         "platform_type VARCHAR NOT NULL,"
         "threat_entry_type VARCHAR NOT NULL,"
-        "timestamp INTEGER NOT NULL DEFAULT (CAST(strftime('%s', 'now') AS INT)),"
         "negative_expires_at INTEGER NOT NULL DEFAULT (CAST(strftime('%s', 'now') AS INT)),"
         "PRIMARY KEY (value, threat_type, platform_type, threat_entry_type),"
         "FOREIGN KEY(threat_type, platform_type, threat_entry_type)"
@@ -325,7 +323,6 @@ ephy_gsb_storage_init_hash_full_table (EphyGSBStorage *self)
         "threat_type VARCHAR NOT NULL,"
         "platform_type VARCHAR NOT NULL,"
         "threat_entry_type VARCHAR NOT NULL,"
-        "timestamp INTEGER NOT NULL DEFAULT (CAST(strftime('%s', 'now') AS INT)),"
         "expires_at INTEGER NOT NULL DEFAULT (CAST(strftime('%s', 'now') AS INT)),"
         "PRIMARY KEY (value, threat_type, platform_type, threat_entry_type)"
         ")";
@@ -659,7 +656,7 @@ ephy_gsb_storage_get_threat_lists (EphyGSBStorage *self)
   g_assert (EPHY_IS_GSB_STORAGE (self));
   g_assert (self->is_operable);
 
-  sql = "SELECT threat_type, platform_type, threat_entry_type, client_state, timestamp FROM threats";
+  sql = "SELECT threat_type, platform_type, threat_entry_type, client_state FROM threats";
   statement = ephy_sqlite_connection_create_statement (self->db, sql, &error);
   if (error) {
     g_warning ("Failed to create select threat lists statement: %s", error->message);
@@ -672,10 +669,8 @@ ephy_gsb_storage_get_threat_lists (EphyGSBStorage *self)
     const char *platform_type = ephy_sqlite_statement_get_column_as_string (statement, 1);
     const char *threat_entry_type = ephy_sqlite_statement_get_column_as_string (statement, 2);
     const char *client_state = ephy_sqlite_statement_get_column_as_string (statement, 3);
-    gint64 timestamp = ephy_sqlite_statement_get_column_as_int64 (statement, 4);
     EphyGSBThreatList *list = ephy_gsb_threat_list_new (threat_type, platform_type,
-                                                        threat_entry_type, client_state,
-                                                        timestamp);
+                                                        threat_entry_type, client_state);
     threat_lists = g_list_prepend (threat_lists, list);
   }
 
@@ -759,12 +754,10 @@ ephy_gsb_storage_update_client_state (EphyGSBStorage    *self,
   g_assert (list);
 
   if (clear) {
-    sql = "UPDATE threats SET "
-          "timestamp=(CAST(strftime('%s', 'now') AS INT)), client_state=NULL "
+    sql = "UPDATE threats SET client_state=NULL "
           "WHERE threat_type=? AND platform_type=? AND threat_entry_type=?";
   } else {
-    sql = "UPDATE threats SET "
-          "timestamp=(CAST(strftime('%s', 'now') AS INT)), client_state=? "
+    sql = "UPDATE threats SET client_state=? "
           "WHERE threat_type=? AND platform_type=? AND threat_entry_type=?";
   }
 
diff --git a/lib/safe-browsing/ephy-gsb-utils.c b/lib/safe-browsing/ephy-gsb-utils.c
index fbe62eb..70c82b1 100644
--- a/lib/safe-browsing/ephy-gsb-utils.c
+++ b/lib/safe-browsing/ephy-gsb-utils.c
@@ -153,8 +153,7 @@ EphyGSBThreatList *
 ephy_gsb_threat_list_new (const char *threat_type,
                           const char *platform_type,
                           const char *threat_entry_type,
-                          const char *client_state,
-                          gint64      timestamp)
+                          const char *client_state)
 {
   EphyGSBThreatList *list;
 
@@ -167,7 +166,6 @@ ephy_gsb_threat_list_new (const char *threat_type,
   list->platform_type = g_strdup (platform_type);
   list->threat_entry_type = g_strdup (threat_entry_type);
   list->client_state = g_strdup (client_state);
-  list->timestamp = timestamp;
 
   return list;
 }
diff --git a/lib/safe-browsing/ephy-gsb-utils.h b/lib/safe-browsing/ephy-gsb-utils.h
index 5a8fa6a..103d331 100644
--- a/lib/safe-browsing/ephy-gsb-utils.h
+++ b/lib/safe-browsing/ephy-gsb-utils.h
@@ -40,11 +40,10 @@ G_BEGIN_DECLS
 #define GSB_THREAT_TYPE_UNWANTED_SOFTWARE  "UNWANTED_SOFTWARE"
 
 typedef struct {
-  char   *threat_type;
-  char   *platform_type;
-  char   *threat_entry_type;
-  char   *client_state;
-  gint64  timestamp;
+  char *threat_type;
+  char *platform_type;
+  char *threat_entry_type;
+  char *client_state;
 } EphyGSBThreatList;
 
 typedef struct {
@@ -66,8 +65,7 @@ typedef struct {
 EphyGSBThreatList       *ephy_gsb_threat_list_new                 (const char *threat_type,
                                                                    const char *platform_type,
                                                                    const char *threat_entry_type,
-                                                                   const char *client_state,
-                                                                   gint64      timestamp);
+                                                                   const char *client_state);
 void                     ephy_gsb_threat_list_free                (EphyGSBThreatList *list);
 gboolean                 ephy_gsb_threat_list_equal               (EphyGSBThreatList *l1,
                                                                    EphyGSBThreatList *l2);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]