aboutsummaryrefslogtreecommitdiff
path: root/src/rss_html_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rss_html_common.c')
-rw-r--r--src/rss_html_common.c10
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]);