[epiphany] adblock: Add PID to names of files used for downloads
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] adblock: Add PID to names of files used for downloads
- Date: Mon, 9 Sep 2019 19:23:26 +0000 (UTC)
commit 28907147d6115b85fe2146f3505421473a5a40c5
Author: Adrian Perez de Castro <aperez igalia com>
Date: Sun Sep 8 13:36:48 2019 +0300
adblock: Add PID to names of files used for downloads
This ensures that disk writes of multiple processes trying to fetch
the same rule set simultaneously will not interfere with each other.
Without this, the downloaded data could easily end up being corrupted
if multiple Epiphany instances are running.
embed/ephy-filters-manager.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/embed/ephy-filters-manager.c b/embed/ephy-filters-manager.c
index f44425402..7d471d916 100644
--- a/embed/ephy-filters-manager.c
+++ b/embed/ephy-filters-manager.c
@@ -363,7 +363,14 @@ filter_info_save_sidecar_finish (GAsyncResult *result,
static GFile *
filter_info_get_source_file (FilterInfo *self)
{
- g_autofree char *filename = g_strconcat (filter_info_get_identifier (self), ".json", NULL);
+ /* It is possible that different Epiphany processes try to download the
+ * same ruleset file simultanously. Using different file names ensures
+ * that they do not step on each other toes when writing the downloaded
+ * data to disk.
+ */
+ g_autofree char *filename = g_strdup_printf ("%s-%" G_PID_FORMAT ".json",
+ filter_info_get_identifier (self),
+ getpid ());
const char *filters_dir = ephy_filters_manager_get_adblock_filters_dir (self->manager);
return g_file_new_build_filename (filters_dir, filename, NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]