diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-07-27 20:14:05 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-27 20:14:05 +0200 |
commit | ec5e3c06084ef9c4b7fd71e4bb04af3fbe77bed9 (patch) | |
tree | deb399105f1d752d8f97f13138ab9ad354df4bbd /src/rss_html_common.c | |
parent | 01a6bc67e70600680a1bbf6b9b5d102192760ae4 (diff) |
Time of html items in json file should be the time of download finished, not the time of start of all downloads
Diffstat (limited to 'src/rss_html_common.c')
-rw-r--r-- | src/rss_html_common.c | 10 |
1 files changed, 8 insertions, 2 deletions
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]); |