dbox-storage.c revision d4002fe1f64d25a792f76fb102ef7dc519cd4e24
/* Copyright (c) 2007-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "path-util.h"
#include "ioloop.h"
#include "fs-api.h"
#include "mkdir-parents.h"
#include "unlink-old-files.h"
#include "mailbox-uidvalidity.h"
#include "mailbox-list-private.h"
#include "index-storage.h"
#include "dbox-storage.h"
#include <stdio.h>
#include <dirent.h>
#include <unistd.h>
#include <utime.h>
struct mailbox_list_settings *set)
{
}
static bool
const char *alt_path2, const char *alt_symlink_path)
{
return FALSE;
}
i_warning("dbox %s: Original ALT=%s, "
return TRUE;
/* FIXME: for backwards compatibility. old versions
created the symlink to mailboxes/ directory, which
was fine with sdbox, but didn't even exist with
mdbox. we'll silently replace the symlink. */
return TRUE;
}
i_warning("dbox %s: Original ALT=%s, "
return TRUE;
}
return FALSE;
}
{
&alt_path);
&alt_path2);
return;
i_error("symlink(%s, %s) failed: %m",
}
}
}
struct mail_namespace *ns,
const char **error_r)
{
const char *error;
args = "";
} else {
}
/* FIXME: the deduplication part doesn't work, because
sdbox renames the files.. */
*error_r = "mail_attachment_fs: "
"sis-queue not currently supported by sdbox";
return -1;
}
error);
return -1;
}
}
return 0;
}
{
}
{
const char *path;
}
{
else {
&dir) <= 0)
return;
}
}
static bool
{
/* check once in a while if there are temp files to clean up */
if (interval == 0) {
/* disabled */
return FALSE;
/* not the time to scan it yet */
return FALSE;
} else {
/* Don't know the ctime yet - look it up. */
return FALSE;
}
}
/* there haven't been any changes to this directory
since we last checked it. If we did an extra stat(),
we need to update the last_scan_time to avoid
stat()ing the next time. */
return stated;
}
const char *prefix =
return TRUE;
}
return FALSE;
}
{
int ret = -1;
/* Just because the index directory exists, it doesn't mean
that the mailbox is selectable. Check that by seeing if
dovecot.index.log exists. If it doesn't, fallback to
checking for the dbox-Mails in the mail root directory.
So this also means that if a mailbox is \NoSelect, listing
it will always do a stat() for dbox-Mails in the mail root
directory. That's not ideal, but this makes the behavior
safer and \NoSelect mailboxes are somewhat rare. */
&index_path) < 0)
return -1;
".log", NULL);
}
if (ret < 0) {
if (ret == 0)
}
if (ret == 0) {
return 0;
return -1;
return -1;
} else {
return -1;
}
}
{
return -1;
/* temp files were scanned. update the last scan timestamp. */
}
return 0;
}
{
struct dirent *d;
int ret = 1;
return 1;
}
path);
return -1;
}
if (*d->d_name == '.')
continue;
ret = 0;
break;
}
path);
ret = -1;
}
return ret;
}
{
const char *alt_path;
int ret;
return ret;
if (mailbox_open(box) < 0)
return -1;
"Mailbox already exists");
return -1;
}
/* if alt path already exists and contains files, rebuild storage so
that we don't start overwriting files. */
if (ret < 0)
return -1;
if (ret == 0) {
"Existing files in alt path, "
"rebuilding storage to avoid losing messages");
return -1;
}
/* dir is empty, ignore it */
}
}
const struct mailbox_update *update)
{
struct mail_index_sync_ctx *sync_ctx;
struct mail_index_view *view;
struct mail_index_transaction *trans;
int ret;
/* use syncing as a lock */
if (ret <= 0) {
return -1;
}
return -1;
}
}
return mail_index_sync_commit(&sync_ctx);
}
{
const char *alt_path;
&alt_path))
return 0;
/* make sure alt storage is mounted. if it's not, abort the rebuild. */
return 0;
return -1;
}
/* try to create the alt directory. if it fails, it means alt
storage isn't mounted. */
return -1;
return 0;
}
{
const void *data;
if (flags_offset < data_size)
}