Browse Source

some reshuffling in maildir_scan() for clarity

wip/uidval-recovery
Oswald Buddenhagen 8 years ago
parent
commit
ec4b21535f
  1. 16
      src/drv_maildir.c

16
src/drv_maildir.c

@ -1008,8 +1008,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
maildir_free_scan( msglist ); maildir_free_scan( msglist );
return DRV_BOX_BAD; return DRV_BOX_BAD;
} }
if ((ctx->gen.opts & OPEN_SIZE) || ((ctx->gen.opts & OPEN_FIND) && uid >= ctx->newuid)) fnl = 0;
nfsnprintf( buf + bl, sizeof(buf) - bl, "%s/%s", subdirs[entry->recent], entry->base );
#ifdef USE_DB #ifdef USE_DB
} else if (ctx->usedb) { } else if (ctx->usedb) {
if ((ret = maildir_set_uid( ctx, entry->base, &uid )) != DRV_OK) { if ((ret = maildir_set_uid( ctx, entry->base, &uid )) != DRV_OK) {
@ -1017,8 +1016,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
return ret; return ret;
} }
entry->uid = uid; entry->uid = uid;
if ((ctx->gen.opts & OPEN_SIZE) || ((ctx->gen.opts & OPEN_FIND) && uid >= ctx->newuid)) fnl = 0;
nfsnprintf( buf + bl, sizeof(buf) - bl, "%s/%s", subdirs[entry->recent], entry->base );
#endif /* USE_DB */ #endif /* USE_DB */
} else { } else {
if ((ret = maildir_obtain_uid( ctx, &uid )) != DRV_OK) { if ((ret = maildir_obtain_uid( ctx, &uid )) != DRV_OK) {
@ -1050,7 +1048,13 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
free( entry->base ); free( entry->base );
entry->base = nfstrndup( buf + bl + 4, fnl ); entry->base = nfstrndup( buf + bl + 4, fnl );
} }
if (ctx->gen.opts & OPEN_SIZE) { int want_size = (ctx->gen.opts & OPEN_SIZE);
int want_tuid = ((ctx->gen.opts & OPEN_FIND) && uid >= ctx->newuid);
if (!want_size && !want_tuid)
continue;
if (!fnl)
nfsnprintf( buf + bl, sizeof(buf) - bl, "%s/%s", subdirs[entry->recent], entry->base );
if (want_size) {
if (stat( buf, &st )) { if (stat( buf, &st )) {
if (errno != ENOENT) { if (errno != ENOENT) {
sys_error( "Maildir error: cannot stat %s", buf ); sys_error( "Maildir error: cannot stat %s", buf );
@ -1060,7 +1064,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
} }
entry->size = st.st_size; entry->size = st.st_size;
} }
if ((ctx->gen.opts & OPEN_FIND) && uid >= ctx->newuid) { if (want_tuid) {
if (!(f = fopen( buf, "r" ))) { if (!(f = fopen( buf, "r" ))) {
if (errno != ENOENT) { if (errno != ENOENT) {
sys_error( "Maildir error: cannot open %s", buf ); sys_error( "Maildir error: cannot open %s", buf );

Loading…
Cancel
Save