aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rwxr-xr-xautomediabin112552 -> 112552 bytes
-rw-r--r--src/main.c1
-rw-r--r--src/rss.c2
-rw-r--r--src/rss_html_common.c12
5 files changed, 11 insertions, 5 deletions
diff --git a/README.md b/README.md
index e7ce86b..a05cc40 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,7 @@ Run automedia without any options to see all options.
2. Automatically remove torrents that have finished seeding, to reduce memory usage and startup time of transmission.
3. Cache string lengths (too many strcat).
4. Convert python plugins to C.
+5. Use torrent add response to track finished torrents. A torrent can finish before it is first checked!
# Requirements
## System
curl, transmission-cli, notify-send (optional)
diff --git a/automedia b/automedia
index 5d7814e..d146ad3 100755
--- a/automedia
+++ b/automedia
Binary files differ
diff --git a/src/main.c b/src/main.c
index b2f238a..e5c5321 100644
--- a/src/main.c
+++ b/src/main.c
@@ -441,6 +441,7 @@ static void sync_rss_html(char *rss_config_dir, char *html_config_dir, char *pro
memset(unfinished_torrents.items, 0, unfinished_torrents.size);
automedia_running = 1;
+ transmission_list_torrents(&transmission_session, torrent_list_check_new_downloads_callback, &unfinished_torrents);
/* running is set to 0 in SIGINT signal handler (ctrl+c) */
while(automedia_running) {
sync_tracked_rss(&transmission_session, rss_config_dir);
diff --git a/src/rss.c b/src/rss.c
index 9486e6e..0e7647e 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -498,7 +498,7 @@ static int add_torrents_in_reverse(TransmissionSession *transmission_session, Bu
result = tracked_item_update_latest(&tracked_item, rss_tracked_dir, added_download_items, torrent_names, torrent_name_index);
for(int i = 0; i < torrent_name_index; ++i) {
- free(torrent_names[torrent_name_index]);
+ free(torrent_names[i]);
}
buffer_deinit(&json_element_buffer);
diff --git a/src/rss_html_common.c b/src/rss_html_common.c
index ba4682b..352a3a2 100644
--- a/src/rss_html_common.c
+++ b/src/rss_html_common.c
@@ -190,6 +190,7 @@ int tracked_item_update_latest(TrackedItem *tracked_item, char *tracked_dir, Dow
}
struct json_value_s *downloaded_json = json_object_get_field_by_name(tracked_item->json_data, "downloaded");
+ struct json_array_s *downloaded_json_array_orig = NULL;
struct json_array_s *downloaded_json_array = NULL;
struct json_array_s new_downloaded_array;
@@ -214,6 +215,7 @@ int tracked_item_update_latest(TrackedItem *tracked_item, char *tracked_dir, Dow
result = -1;
goto cleanup;
}
+ downloaded_json_array_orig = downloaded_json_array;
} else {
downloaded_json_array = &new_downloaded_array;
}
@@ -313,10 +315,12 @@ int tracked_item_update_latest(TrackedItem *tracked_item, char *tracked_dir, Dow
downloaded_json_array->length = 1;
last_downloaded_element = &new_downloaded_item_element[i];
- struct json_object_element_s *prev_start = tracked_item->json_data->start;
- tracked_item->json_data->start = &new_downloaded_array_obj_el;
- new_downloaded_array_obj_el.next = prev_start;
- tracked_item->json_data->length++;
+ if(!downloaded_json_array_orig) {
+ struct json_object_element_s *prev_start = tracked_item->json_data->start;
+ tracked_item->json_data->start = &new_downloaded_array_obj_el;
+ new_downloaded_array_obj_el.next = prev_start;
+ tracked_item->json_data->length++;
+ }
}
}