aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-09-27 02:56:13 +0200
committerdec05eba <dec05eba@protonmail.com>2020-09-27 03:29:34 +0200
commita0707a1cf4583f7f00a6fbce2f50fecd09ca7be0 (patch)
tree88bbe0668f1326087a991fc10af9ff5295936ac1
parent836eda9a772ae91a76adffaadfe098bcc82d4d3d (diff)
Fix multiple items using the same timestamp if updated at the same time
They should use their download finished time instead
-rwxr-xr-xautomediabin116632 -> 116632 bytes
-rw-r--r--src/html.c2
-rw-r--r--src/main.c1
-rw-r--r--src/rss_html_common.c8
4 files changed, 8 insertions, 3 deletions
diff --git a/automedia b/automedia
index fe816ec..413b715 100755
--- a/automedia
+++ b/automedia
Binary files differ
diff --git a/src/html.c b/src/html.c
index 6442188..b7abbdf 100644
--- a/src/html.c
+++ b/src/html.c
@@ -379,6 +379,8 @@ static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *d
break;
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);
++download_item_index;
}
diff --git a/src/main.c b/src/main.c
index c300253..359347d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -454,6 +454,7 @@ static void sync_rss_html(char *rss_config_dir, char *html_config_dir, char *pro
while(automedia_running) {
sync_tracked_rss(&transmission_session, rss_config_dir);
sync_tracked_html(html_config_dir, program_dir, download_dir);
+ fprintf(stderr, "Finished syncing rss and html. Syncing again in 15 minutes\n");
int check_count = 0;
while(automedia_running && check_count < sync_rate_sec/check_torrent_status_rate_sec) {
diff --git a/src/rss_html_common.c b/src/rss_html_common.c
index e383117..168195e 100644
--- a/src/rss_html_common.c
+++ b/src/rss_html_common.c
@@ -254,6 +254,8 @@ int tracked_item_update_latest(TrackedItem *tracked_item, char *tracked_dir, Dow
struct json_value_s new_downloaded_json_val[MAX_UPDATE_ITEMS];
struct json_array_element_s new_downloaded_item_element[MAX_UPDATE_ITEMS];
+ char items_timestamps[MAX_UPDATE_ITEMS][32];
+
struct json_array_element_s *last_downloaded_element = NULL;
for(int i = 0; i < num_download_items; ++i) {
create_json_string(&title_json_value_str[i], download_items[i]->title, strlen(download_items[i]->title));
@@ -264,9 +266,9 @@ 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);
+ sprintf(items_timestamps[i], "%ld", timestamps[i]);
+ int updated_len = strlen(items_timestamps[i]);
+ create_json_string(&time_value_str[i], items_timestamps[i], updated_len);
init_json_value_str(&time_json_value[i], &time_value_str[i]);
create_json_string(&url_value_str[i], download_items[i]->link, strlen(download_items[i]->link));