diff options
author | Richard Hughes <richard@hughsie.com> | 2016-02-02 12:19:30 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2016-02-02 12:19:30 +0000 |
commit | f49fb62d90cc7af8aa1b6407d1b1b324718012a3 (patch) | |
tree | bf9bfeffb70b0e3d44425f58ca051da7e1039cca | |
parent | 300d50119820e32f56a2c3d52d9704d835ba444d (diff) | |
download | appstream-glib-f49fb62d90cc7af8aa1b6407d1b1b324718012a3.tar.gz |
Ignore temp and hidden files in AsMonitor
-rw-r--r-- | libappstream-glib/as-monitor.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libappstream-glib/as-monitor.c b/libappstream-glib/as-monitor.c index ba46d5e..668fb71 100644 --- a/libappstream-glib/as-monitor.c +++ b/libappstream-glib/as-monitor.c @@ -347,6 +347,7 @@ as_monitor_file_changed_cb (GFileMonitor *mon, AsMonitorPrivate *priv = GET_PRIVATE (monitor); const gchar *tmp; gboolean is_temp; + g_autofree gchar *basename = NULL; g_autofree gchar *filename = NULL; g_autofree gchar *filename_other = NULL; @@ -358,6 +359,18 @@ as_monitor_file_changed_cb (GFileMonitor *mon, g_debug ("modified: %s %s [%i]", filename, _g_file_monitor_to_string (event_type), is_temp); + /* ignore hidden files */ + basename = g_path_get_basename (filename); + if (g_str_has_prefix (basename, ".")) { + g_debug ("ignoring hidden file"); + return; + } + if (g_str_has_suffix (basename, ".swx") || + g_str_has_suffix (basename, ".swp")) { + g_debug ("ignoring temp file"); + return; + } + switch (event_type) { case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: as_monitor_process_pending (monitor); |