Adblock: Check if file is up to date before parsing it

This commit is contained in:
Paweł Forysiuk 2012-09-01 17:54:30 +02:00 committed by Christian Dywan
parent c49fb82e87
commit be61f96bc2
1 changed files with 5 additions and 6 deletions

View File

@ -43,7 +43,7 @@ static GHashTable* blockcssprivate = NULL;
static GHashTable* navigationwhitelist = NULL; static GHashTable* navigationwhitelist = NULL;
static GString* blockcss = NULL; static GString* blockcss = NULL;
static gboolean static void
adblock_parse_file (gchar* path); adblock_parse_file (gchar* path);
static gboolean static gboolean
@ -226,8 +226,7 @@ adblock_reload_rules (MidoriExtension* extension,
continue; continue;
} }
if (!adblock_parse_file (path) if (!adblock_file_is_up_to_date (path))
|| !adblock_file_is_up_to_date (path))
{ {
WebKitNetworkRequest* request; WebKitNetworkRequest* request;
WebKitDownload* download; WebKitDownload* download;
@ -242,6 +241,8 @@ adblock_reload_rules (MidoriExtension* extension,
G_CALLBACK (adblock_download_notify_status_cb), extension); G_CALLBACK (adblock_download_notify_status_cb), extension);
webkit_download_start (download); webkit_download_start (download);
} }
else
adblock_parse_file (path);
g_free (path); g_free (path);
i++; i++;
} }
@ -1596,7 +1597,7 @@ adblock_file_is_up_to_date (gchar* path)
return FALSE; return FALSE;
} }
static gboolean static void
adblock_parse_file (gchar* path) adblock_parse_file (gchar* path)
{ {
FILE* file; FILE* file;
@ -1607,9 +1608,7 @@ adblock_parse_file (gchar* path)
while (fgets (line, 2000, file)) while (fgets (line, 2000, file))
adblock_parse_line (line); adblock_parse_line (line);
fclose (file); fclose (file);
return TRUE;
} }
return FALSE;
} }
static void static void