From e9ff36f9985e669317043f80b8edf5d17d4c0c3e Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 19 Mar 2025 22:07:09 +0100 Subject: Add option to not show error notification --- src/html.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/html.c') diff --git a/src/html.c b/src/html.c index a0a5e73..40cc1eb 100644 --- a/src/html.c +++ b/src/html.c @@ -382,7 +382,7 @@ static int int_min(int a, int b) { return a < b ? a : b; } -static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *download_items_buffer, TrackedHtml *tracked_html, char *html_tracked_dir, const char *download_dir) { +static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *download_items_buffer, TrackedHtml *tracked_html, char *html_tracked_dir, const char *download_dir, bool show_error_notifications) { const char *home_dir = get_home_dir(); char download_finished_script[PATH_MAX]; @@ -426,8 +426,10 @@ static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *d if(result != 0) fprintf(stderr, "Failed while downloading html, url: %s\n", download_items_it->link); - const char *notify_args[] = { "notify-send", "-a", "automedia", "-u", result == 0 ? "low" : "critical", "-t", "5000", "--", result == 0 ? "Download finished" : "Download failed", notify_msg, NULL }; - program_exec(notify_args, NULL, NULL); + if(result == 0 || show_error_notifications) { + const char *notify_args[] = { "notify-send", "-a", "automedia", "-u", result == 0 ? "low" : "critical", "-t", "5000", "--", result == 0 ? "Download finished" : "Download failed", notify_msg, NULL }; + program_exec(notify_args, NULL, NULL); + } if(result != 0) break; @@ -455,7 +457,7 @@ static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *d } /* TODO: Make asynchronous. Right now this will only complete when the whole chapter download completes */ -int sync_html(TrackedHtml *tracked_html, char *program_dir, const char *download_dir, char *html_config_dir) { +int sync_html(TrackedHtml *tracked_html, char *program_dir, const char *download_dir, char *html_config_dir, bool show_error_notifications) { /* TODO: This can be cached */ int html_config_dir_len = strlen(html_config_dir); @@ -486,7 +488,7 @@ int sync_html(TrackedHtml *tracked_html, char *program_dir, const char *download char *html_tracked_dir = html_config_dir; strcat(html_tracked_dir, "/tracked/"); - result = download_html_items_in_reverse(plugin_filepath, &download_items_buffer, tracked_html, html_tracked_dir, download_dir); + result = download_html_items_in_reverse(plugin_filepath, &download_items_buffer, tracked_html, html_tracked_dir, download_dir, show_error_notifications); if(result != 0) { fprintf(stderr, "Failed while download html item for url: %s\n", tracked_html->link); goto cleanup; -- cgit v1.2.3-70-g09d2