simplify assembly of IMAP APPEND commands

treat the date string the same as the flag string.

amends eb1f1076.
This commit is contained in:
Oswald Buddenhagen 2022-06-19 12:36:47 +02:00
parent 4ae0159132
commit abd31aad61

View File

@ -3233,6 +3233,14 @@ imap_store_msg( store_t *gctx, msg_data_t *data, int to_trash,
flagstr[d++] = ' '; flagstr[d++] = ' ';
} }
flagstr[d] = 0; flagstr[d] = 0;
if (data->date) {
DIAG_PUSH
DIAG_DISABLE("-Wformat") // configure ensures that %z actually works.
strftime( datestr, sizeof(datestr), "\"%d-%b-%Y %H:%M:%S %z\" ", localtime( &data->date ) );
DIAG_POP
} else {
datestr[0] = 0;
}
INIT_IMAP_CMD(imap_cmd_out_uid_t, cmd, cb, aux) INIT_IMAP_CMD(imap_cmd_out_uid_t, cmd, cb, aux)
ctx->buffer_mem += data->len; ctx->buffer_mem += data->len;
@ -3255,18 +3263,8 @@ imap_store_msg( store_t *gctx, msg_data_t *data, int to_trash,
return; return;
} }
} }
if (data->date) { imap_exec( ctx, &cmd->gen, imap_store_msg_p2,
/* configure ensures that %z actually works. */ "APPEND \"%\\s\" %s%s", buf, flagstr, datestr );
DIAG_PUSH
DIAG_DISABLE("-Wformat")
strftime( datestr, sizeof(datestr), "%d-%b-%Y %H:%M:%S %z", localtime( &data->date ) );
DIAG_POP
imap_exec( ctx, &cmd->gen, imap_store_msg_p2,
"APPEND \"%\\s\" %s\"%\\s\" ", buf, flagstr, datestr );
} else {
imap_exec( ctx, &cmd->gen, imap_store_msg_p2,
"APPEND \"%\\s\" %s", buf, flagstr );
}
free( buf ); free( buf );
} }