include expunges in progress counters

This commit is contained in:
Oswald Buddenhagen 2022-05-10 13:30:17 +02:00
parent 8fbc4323f4
commit edc901b7af
5 changed files with 48 additions and 11 deletions

1
NEWS
View File

@ -19,6 +19,7 @@ MaxMessages and MaxSize can be used together now.
The unfiltered list of mailboxes in each Store can be printed now.
A proper summary is now printed prior to exiting.
This includes expunges, which are now included in the progress as well.
Added new sync operation 'Old'.

View File

@ -9,7 +9,7 @@
#define nz(a, b) ((a) ? (a) : (b))
static int ops_any[2], trash_any[2];
static int ops_any[2], trash_any[2], expunge_any[2];
static int chans_total, chans_done;
static int boxes_total, boxes_done;
@ -20,7 +20,7 @@ static wakeup_t stats_wakeup;
static void
print_stats( void )
{
char buf[3][64];
char buf[3][80];
char *cs;
static int cols = -1;
@ -29,10 +29,11 @@ print_stats( void )
int ll = sprintf( buf[2], "C: %d/%d B: %d/%d", chans_done, chans_total, boxes_done, boxes_total );
int cls = (cols - ll - 10) / 2;
for (int t = 0; t < 2; t++) {
int l = sprintf( buf[t], "+%d/%d *%d/%d #%d/%d",
int l = sprintf( buf[t], "+%d/%d *%d/%d #%d/%d -%d/%d",
new_done[t], new_total[t],
flags_done[t], flags_total[t],
trash_done[t], trash_total[t] );
trash_done[t], trash_total[t],
expunge_done[t], expunge_total[t] );
if (l > cls)
buf[t][cls - 1] = '~';
}
@ -91,6 +92,11 @@ summary( void )
",\nwould move %d %s message(s) to trash" :
",\nmoved %d %s message(s) to trash",
trash_done[t], str_fn[t] );
if (expunge_any[t])
printf( (DFlags & DRYRUN) ?
",\nwould expunge %d message(s) from %s" :
",\nexpunged %d message(s) from %s",
expunge_done[t], str_fn[t] );
}
puts( "." );
}
@ -235,10 +241,12 @@ add_channel( chan_ent_t ***chanapp, channel_conf_t *chan, int ops[] )
}
if (chan->ops[t] & OP_MASK_TYPE)
ops_any[t] = 1;
if ((chan->ops[t] & (OP_EXPUNGE | OP_EXPUNGE_SOLO)) &&
(chan->stores[t]->trash ||
(chan->stores[t^1]->trash && chan->stores[t^1]->trash_remote_new)))
trash_any[t] = 1;
if (chan->ops[t] & (OP_EXPUNGE | OP_EXPUNGE_SOLO)) {
expunge_any[t] = 1;
if (chan->stores[t]->trash ||
(chan->stores[t^1]->trash && chan->stores[t^1]->trash_remote_new))
trash_any[t] = 1;
}
}
**chanapp = ce;

View File

@ -779,13 +779,13 @@ If \fBmbsync\fR's output is connected to a console, it will print progress
counters by default. The output will look like this:
.P
.in +4
C: 1/2 B: 3/4 F: +13/13 *23/42 #0/0 N: +0/7 *0/0 #0/0
C: 1/2 B: 3/4 F: +13/13 *23/42 #0/0 -0/0 N: +0/7 *0/0 #0/0 -0/0
.in -4
.P
This represents the cumulative progress over Channels, boxes, and messages
affected on the far and near side, respectively.
The message counts represent added messages, messages with updated flags,
and trashed messages, respectively.
trashed messages, and expunged messages, respectively.
No attempt is made to calculate the totals in advance, so they grow over
time as more information is gathered.
.P

View File

@ -17,6 +17,7 @@ uint BufferLimit = 10 * 1024 * 1024;
int new_total[2], new_done[2];
int flags_total[2], flags_done[2];
int trash_total[2], trash_done[2];
int expunge_total[2], expunge_done[2];
static void sync_ref( sync_vars_t *svars ) { ++svars->ref_count; }
static void sync_deref( sync_vars_t *svars );
@ -286,6 +287,10 @@ message_expunged( message_t *msg, void *aux )
msg->srec->msg[t] = NULL;
msg->srec = NULL;
}
if (msg->status & M_EXPUNGE) {
expunge_done[t]++;
stats();
}
}
static void box_confirmed( int sts, uint uidvalidity, void *aux );
@ -1771,6 +1776,25 @@ sync_close( sync_vars_t *svars, int t )
if ((svars->chan->ops[t] & (OP_EXPUNGE | OP_EXPUNGE_SOLO)) && !(DFlags & FAKEEXPUNGE)
/*&& !(svars->state[t] & ST_TRASH_BAD)*/) {
if (Verbosity >= TERSE) {
if (svars->opts[t] & OPEN_UID_EXPUNGE) {
for (message_t *tmsg = svars->msgs[t]; tmsg; tmsg = tmsg->next) {
if (tmsg->status & M_DEAD)
continue;
if (tmsg->status & M_EXPUNGE)
expunge_total[t]++;
}
} else {
for (sync_rec_t *srec = svars->srecs; srec; srec = srec->next) {
if (srec->status & S_DEAD)
continue;
if (srec->status & S_DEL(t))
expunge_total[t]++;
}
}
stats();
}
debug( "expunging %s\n", str_fn[t] );
svars->drv[t]->close_box( svars->ctx[t], box_closed, AUX );
} else {
@ -1792,9 +1816,12 @@ box_closed( int sts, int reported, void *aux )
// by a refresh, and in the extremely unlikely case of this happening
// on both sides, we'd even get a duplicate. That's why this is only
// a fallback.
if (srec->status & S_DEL(t))
if (srec->status & S_DEL(t)) {
srec->status |= S_GONE(t);
expunge_done[t]++;
}
}
stats();
}
box_closed_p2( svars, t );
}

View File

@ -77,6 +77,7 @@ extern uint BufferLimit;
extern int new_total[2], new_done[2];
extern int flags_total[2], flags_done[2];
extern int trash_total[2], trash_done[2];
extern int expunge_total[2], expunge_done[2];
extern const char *str_fn[2], *str_hl[2];