aboutsummaryrefslogtreecommitdiff
path: root/src/rss.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rss.c')
-rw-r--r--src/rss.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/rss.c b/src/rss.c
index cc31610..c8bdd2d 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -480,6 +480,10 @@ static int rss_parse_sync_callback(const char *title, const char *link, void *us
return 0;
}
+static int int_min(int a, int b) {
+ return a < b ? a : b;
+}
+
static int add_torrents_in_reverse(TransmissionSession *transmission_session, Buffer *download_items_buffer, TrackedRss *tracked_rss, char *rss_tracked_dir) {
int result = 0;
char *torrent_names[MAX_UPDATE_ITEMS];
@@ -491,6 +495,7 @@ static int add_torrents_in_reverse(TransmissionSession *transmission_session, Bu
DownloadItemsData *download_items_it = buffer_end(download_items_buffer);
DownloadItemsData *download_items_end = buffer_begin(download_items_buffer);
+ const size_t num_items_to_download = int_min(download_items_it - download_items_end, MAX_UPDATE_ITEMS);
download_items_it--;
download_items_end--;
int torrent_name_index = 0;
@@ -502,7 +507,7 @@ static int add_torrents_in_reverse(TransmissionSession *transmission_session, Bu
break;
}
added_download_items[torrent_name_index] = download_items_it;
- timestamps[torrent_name_index] = time(NULL);
+ timestamps[torrent_name_index] = time(NULL) - num_items_to_download + (torrent_name_index + 1);
++torrent_name_index;
/* Show notification that download has started? */
}