From 84194a7a9fdd179ca15e4b069a3cffbeaec03bab Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 10 Jan 2023 11:37:26 +0100 Subject: [PATCH] don't try to create already existing boxes if the SELECT command fails even though the box was LISTed, then the error cause is obviously not that box is absent, and so we should not attempt to CREATE it. --- src/sync.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/sync.c b/src/sync.c index bff3684..c66370c 100644 --- a/src/sync.c +++ b/src/sync.c @@ -377,10 +377,13 @@ sync_boxes( store_t *ctx[], const char * const names[], int present[], channel_c sync_ref( svars ); for (t = 0; ; t++) { info( "Opening %s box %s...\n", str_fn[t], svars->orig_name[t] ); - if (present[t] == BOX_ABSENT) + if (present[t] == BOX_ABSENT) { box_confirmed2( svars, t ); - else + } else { + if (present[t] == BOX_PRESENT) + svars->state[t] |= ST_PRESENT; svars->drv[t]->open_box( ctx[t], box_confirmed, AUX ); + } if (t || check_cancel( svars )) break; } @@ -399,6 +402,12 @@ box_confirmed( int sts, uint uidvalidity, void *aux ) if (sts == DRV_OK) { svars->state[t] |= ST_PRESENT; svars->newuidval[t] = uidvalidity; + } else if (svars->state[t] & ST_PRESENT) { + error( "Error: channel %s: %s box %s cannot be opened.\n", + svars->chan->name, str_fn[t], svars->orig_name[t] ); + svars->ret |= SYNC_FAIL; + cancel_sync( svars ); + return; } box_confirmed2( svars, t ); }