aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-01-01 11:46:59 +0100
committerdec05eba <dec05eba@protonmail.com>2023-01-01 11:46:59 +0100
commit3415f650eaff56e9a2980f7942e3e80444bc4100 (patch)
tree6c1503b528e240ae58c0c2d196cfddbdb7b4e9b2
parent3767bb74de0926cbb24afc709a249f62b858b7a8 (diff)
Show how many days old cleanup items are
-rw-r--r--TODO1
-rw-r--r--src/main.c10
2 files changed, 9 insertions, 2 deletions
diff --git a/TODO b/TODO
index 0fc4238..e34eed7 100644
--- a/TODO
+++ b/TODO
@@ -9,3 +9,4 @@ Handle strdup failure.
Make downloading manga asynchronous, just like torrents. And have timeout for download.
Detect if a website is very slow (timeout?) and ignore sync for that website for the current sync. This is to prevent a slow website from preventing all syncs..
Cleanup command should remove torrents from transmission.
+Remove dirname because it breaks automedia.pid because it modified /proc/.../cmdline. Should also do readlink on the first arg of cmdline (which doesn't work if automedia is in /usr/bin???). Use socket! look at quickmedia.
diff --git a/src/main.c b/src/main.c
index 34895c6..c84ca68 100644
--- a/src/main.c
+++ b/src/main.c
@@ -729,6 +729,10 @@ static int compare_tracked_item(const void *a, const void *b) {
return list_data_a->updated_time - list_data_b->updated_time;
}
+static int time_diff_to_days(time_t start, time_t end) {
+ return (end - start) / 60LL / 60LL / 24LL;
+}
+
static void command_cleanup(int argc, char **argv, const char *rss_config_dir, const char *html_config_dir) {
time_t days = 0;
const char *search_term = NULL;
@@ -780,13 +784,14 @@ static void command_cleanup(int argc, char **argv, const char *rss_config_dir, c
qsort(tracked_items.data, num_rss_items, sizeof(TrackedItemData), compare_tracked_item);
qsort((TrackedItemData*)tracked_items.data + num_rss_items, num_tracked_items - num_rss_items, sizeof(TrackedItemData), compare_tracked_item);
+ time_t time_now = time(NULL);
TrackedItemData *list_begin = buffer_begin(&tracked_items);
TrackedItemData *list_it = list_begin;
TrackedItemData *list_end = buffer_end(&tracked_items);
int index = 0;
for(; list_it != list_end; ++list_it) {
const char *name = path_get_filename(list_it->item_tracked_path);
- printf("%d %s/%s\n", 1 + index, index < num_rss_items ? "rss" : "html", name);
+ printf("%d (last updated: %d day(s) ago): %s/%s\n", 1 + index, (int)time_diff_to_days(list_it->updated_time, time_now), index < num_rss_items ? "rss" : "html", name);
++index;
}
@@ -862,6 +867,7 @@ static void command_cleanup(int argc, char **argv, const char *rss_config_dir, c
continue;
for(;;) {
+ time_now = time(NULL);
size_t *tracks_to_remove_it = buffer_begin(&tracks_to_remove);
size_t *tracks_to_remove_end = buffer_end(&tracks_to_remove);
fprintf(stderr, "==> Are you sure you want to stop tracking:\n");
@@ -869,7 +875,7 @@ static void command_cleanup(int argc, char **argv, const char *rss_config_dir, c
const size_t track_index = *tracks_to_remove_it;
TrackedItemData *track_item = &list_begin[track_index];
const char *name = path_get_filename(track_item->item_tracked_path);
- printf(" %s/%s\n", track_index < (size_t)num_rss_items ? "rss" : "html", name);
+ printf(" (last updated: %d day(s) ago): %s/%s\n", (int)time_diff_to_days(track_item->updated_time, time_now), track_index < (size_t)num_rss_items ? "rss" : "html", name);
}
fprintf(stderr, "==> Yes/No: ");