aboutsummaryrefslogtreecommitdiff
path: root/src/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/html.c')
-rw-r--r--src/html.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/html.c b/src/html.c
index e8ddd23..cb9904e 100644
--- a/src/html.c
+++ b/src/html.c
@@ -378,6 +378,10 @@ int add_html(const char *name, const char *url, char *html_config_dir, char *pro
return result;
}
+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) {
const char *home_dir = get_home_dir();
@@ -398,6 +402,7 @@ static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *d
DownloadItemsData *download_items_it = buffer_end(download_items_buffer);
DownloadItemsData *download_items_end = buffer_begin(download_items_buffer);
+ const size_t num_items_to_download = int_min(download_items_it - download_items_end, MAX_UPDATE_ITEMS);
download_items_it--;
download_items_end--;
int download_item_index = 0;
@@ -436,7 +441,7 @@ static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *d
added_download_items[download_item_index] = download_items_it;
// TODO: What if the download is so fast two items have the same timestamp? Maybe substract by MAX_UPDATE_ITEMS and then add 1 each loop,
// or use milliseconds/microseconds timestamps?
- timestamps[download_item_index] = time(NULL);
+ timestamps[download_item_index] = time(NULL) - num_items_to_download + (download_item_index + 1);
++download_item_index;
}