seq_read and seq_list also recognise msg which don't exist
authorPhilipp Takacs <philipp@bureaucracy.de>
Wed, 18 Mar 2020 18:53:25 +0000 (19:53 +0100)
committerPhilipp Takacs <philipp@bureaucracy.de>
Sun, 29 Mar 2020 19:23:55 +0000 (21:23 +0200)
This allows better handling of raceconditions, like a new mail gets
deliverd while a unreed mail is shown.

sbr/seq_list.c
sbr/seq_read.c
test/tests/show/test-unseen-update

index 3606f6f..ce23c22 100644 (file)
@@ -54,12 +54,9 @@ seq_list(struct msgs *mp, char *seqname)
 
        bp = buffer;
 
-       for (i = mp->lowmsg; i <= mp->hghmsg; ++i) {
-               /*
-               ** If message doesn't exist, or isn't in
-               ** the sequence, then continue.
-               */
-               if (!does_exist(mp, i) || !in_sequence(mp, seqnum, i))
+       for (i = mp->lowoff; i <= mp->hghoff; ++i) {
+               /* If message isn't in the sequence, then continue */
+               if (!in_sequence(mp, seqnum, i))
                        continue;
 
                /*
@@ -91,8 +88,7 @@ seq_list(struct msgs *mp, char *seqname)
                /*
                ** Scan to the end of this message range
                */
-               for (++i; i <= mp->hghmsg && does_exist(mp, i) &&
-                               in_sequence(mp, seqnum, i); ++i)
+               for (++i; i <= mp->hghoff && in_sequence(mp, seqnum, i); ++i)
                        ;
 
                if (i - j > 1) {
index 041f632..4cc4223 100644 (file)
@@ -210,9 +210,14 @@ seq_init(struct msgs *mp, char *name, char *field)
                        ** We iterate through messages in this range
                        ** and flip on bit for this sequence.
                        */
+                       if (k > mp->hghoff) {
+                               if (!(mp = folder_realloc(mp, mp->lowoff, k))) {
+                                       adios(EX_OSERR, NULL, "unable to allocate folder storage");
+                               }
+                               mp->hghoff = k;
+                       }
                        for (; j <= k; j++) {
-                               if (j >= mp->lowmsg && j <= mp->hghmsg &&
-                                               does_exist(mp, j))
+                               if (j >= mp->lowmsg && j <= mp->hghoff)
                                        add_sequence(mp, i, j);
                        }
                }
index a4875c4..61e317e 100644 (file)
@@ -24,7 +24,14 @@ runandcheck "pick u" <<!
 8
 9
 !
-mark -sequence u -add -nozero 10
+
+#add a new mail
+rcvstore <<!
+From: test
+To: test
+
+testmail
+!
 runandcheck "pick u" <<!
 1
 2
@@ -35,12 +42,12 @@ runandcheck "pick u" <<!
 7
 8
 9
-10
+11
 !
 pkill -P $pagerpid
 wait $pagerpid
 
 runandcheck "pick u" <<!
 9
-10
+11
 !