]> git.tuebingen.mpg.de Git - dss.git/commitdiff
ls: Print current duration of incomplete snapshots.
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 15 Oct 2017 19:11:46 +0000 (21:11 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 5 Nov 2017 23:33:54 +0000 (00:33 +0100)
Currently the duration of incomplete (and orphaned) snapshots is shown
as 0:00. It's more interesting to see for how long the snapshot is
already being created, so print the difference of the current time
and the start time instead.

Fix an overlong line and a whitespace issue while at it.

dss.c

diff --git a/dss.c b/dss.c
index 3e626ab0113b1890277da115ea6c735dbdb690d7..122472ec49a448e7166cdb0b70e1ea1e0b356931 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -1683,13 +1683,17 @@ static int com_ls(void)
        int i;
        struct snapshot_list sl;
        struct snapshot *s;
+       int64_t now = get_current_time();
 
        dss_get_snapshot_list(&sl);
        FOR_EACH_SNAPSHOT(s, i, &sl) {
-               int64_t d = 0;
+               int64_t d;
                if (s->flags & SS_COMPLETE)
                        d = (s->completion_time - s->creation_time) / 60;
-               dss_msg("%u\t%s\t%3" PRId64 ":%02" PRId64 "\n", s->interval, s->name, d/60, d%60);
+               else
+                       d = (now - s->creation_time) / 60;
+               dss_msg("%u\t%s\t%3" PRId64 ":%02" PRId64 "\n", s->interval,
+                       s->name, d / 60, d % 60);
        }
        free_snapshot_list(&sl);
        return 1;