From ec5e3c06084ef9c4b7fd71e4bb04af3fbe77bed9 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 27 Jul 2020 20:14:05 +0200 Subject: Time of html items in json file should be the time of download finished, not the time of start of all downloads --- src/rss_html_common.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/rss_html_common.c') diff --git a/src/rss_html_common.c b/src/rss_html_common.c index 352a3a2..e383117 100644 --- a/src/rss_html_common.c +++ b/src/rss_html_common.c @@ -162,8 +162,12 @@ static struct json_array_element_s* get_last_element_in_json_array(struct json_a } /* TODO: If this fails in the middle, recover and update the next time somehow */ -int tracked_item_update_latest(TrackedItem *tracked_item, char *tracked_dir, DownloadItemsData **download_items, char **filenames, int num_download_items) { +int tracked_item_update_latest(TrackedItem *tracked_item, char *tracked_dir, DownloadItemsData **download_items, char **filenames, long *timestamps, int num_download_items) { + if(num_download_items == 0) + return 0; + assert(num_download_items <= MAX_UPDATE_ITEMS); + assert(timestamps); int tracked_dir_len = strlen(tracked_dir); int result = 0; @@ -172,7 +176,7 @@ int tracked_item_update_latest(TrackedItem *tracked_item, char *tracked_dir, Dow char updated[32]; assert(sizeof(time_t) == sizeof(long)); - sprintf(updated, "%ld", time(NULL)); + sprintf(updated, "%ld", timestamps[num_download_items - 1]); int updated_len = strlen(updated); result = file_overwrite_in_dir(item_filepath, "updated", updated, updated_len); if(result != 0) { @@ -260,6 +264,8 @@ int tracked_item_update_latest(TrackedItem *tracked_item, char *tracked_dir, Dow init_json_value_str(&filename_json_value[i], &filename_json_value_str[i]); } + sprintf(updated, "%ld", timestamps[i]); + int updated_len = strlen(updated); create_json_string(&time_value_str[i], updated, updated_len); init_json_value_str(&time_json_value[i], &time_value_str[i]); -- cgit v1.2.3