maildir-util.c revision 7ede6554e451ec039a67beec7d6ee4aff61d386e
/* Copyright (c) 2004-2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "ioloop.h"
#include "str.h"
#include "mkdir-parents.h"
#include "maildir-storage.h"
#include "maildir-uidlist.h"
#include "maildir-keywords.h"
#include "maildir-filename.h"
#include "maildir-sync.h"
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <utime.h>
#define MAILDIR_RESYNC_RETRY_COUNT 10
static const char *
const char *fname, bool *have_flags_r)
{
struct maildir_keywords_sync_ctx *kw_ctx;
enum mail_flags flags;
*have_flags_r = FALSE;
return fname;
}
if (array_count(&keywords) == 0) {
} else {
*have_flags_r = TRUE;
}
return fname;
}
{
bool have_flags;
int ret;
if (ret <= 0)
if ((flags & MAILDIR_UIDLIST_REC_FLAG_NONSYNCED) != 0) {
/* let's see if we can guess the filename based on index */
if (have_flags) {
/* don't even bother looking into new/ dir */
}
}
if ((flags & MAILDIR_UIDLIST_REC_FLAG_NEW_DIR) != 0) {
/* probably in new/ dir */
if (ret != 0)
return ret;
}
return ret;
}
void *context ATTR_UNUSED)
{
/* most likely a symlink pointing to a non-existing file */
"Maildir: Symlink destination doesn't exist: %s", path);
return -2;
} else {
"maildir_file_do(%s): Filename keeps changing", path);
return -1;
}
}
{
int i, ret;
T_BEGIN {
} T_END;
for (i = 0; i < MAILDIR_RESYNC_RETRY_COUNT && ret == 0; i++) {
/* file is either renamed or deleted. sync the maildir and
see which one. if file appears to be renamed constantly,
don't try to open it more than 10 times. */
return -1;
T_BEGIN {
} T_END;
}
if (i == MAILDIR_RESYNC_RETRY_COUNT) T_BEGIN {
} T_END;
}
{
const char *path;
unsigned int i;
/* @UNSAFE: get a list of directories we want to create */
for (i = 0; i < N_ELEMENTS(subdirs); i++)
for (i = 0; i < N_ELEMENTS(dirs); i++) {
continue;
"stat(%s) failed: %m", path);
break;
}
/* mailbox was being deleted just now */
break;
}
"mkdir(%s) failed: %m", path);
break;
}
}
}
{
int ret;
else {
}
return FALSE;
}
/* maildir itself exists. create all of its subdirectories in case
they got lost. */
T_BEGIN {
} T_END;
}