dovecot: Removed maildir_tmp_cleanup(). Use unlink_old_files() i...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Dec 8 17:11:19 EET 2007
details: http://hg.dovecot.org/dovecot/rev/7ae8505870c1
changeset: 6958:7ae8505870c1
user: Timo Sirainen <tss at iki.fi>
date: Sat Dec 08 17:10:18 2007 +0200
description:
Removed maildir_tmp_cleanup(). Use unlink_old_files() instead.
diffstat:
3 files changed, 4 insertions(+), 80 deletions(-)
src/lib-storage/index/maildir/maildir-storage.c | 5 +
src/lib-storage/index/maildir/maildir-storage.h | 1
src/lib-storage/index/maildir/maildir-util.c | 78 -----------------------
diffs (127 lines):
diff -r d421f14ba797 -r 7ae8505870c1 src/lib-storage/index/maildir/maildir-storage.c
--- a/src/lib-storage/index/maildir/maildir-storage.c Sat Dec 08 17:05:17 2007 +0200
+++ b/src/lib-storage/index/maildir/maildir-storage.c Sat Dec 08 17:10:18 2007 +0200
@@ -8,6 +8,7 @@
#include "home-expand.h"
#include "mkdir-parents.h"
#include "unlink-directory.h"
+#include "unlink-old-files.h"
#include "maildir-storage.h"
#include "maildir-uidlist.h"
#include "maildir-keywords.h"
@@ -322,13 +323,15 @@ static int maildir_check_tmp(struct mail
mail_storage_set_critical(storage, "stat(%s) failed: %m", path);
return -1;
}
+ st.st_atime = 0;
if (st.st_atime > st.st_ctime + MAILDIR_TMP_DELETE_SECS) {
/* the directory should be empty. we won't do anything
until ctime changes. */
} else if (st.st_atime < ioloop_time - MAILDIR_TMP_SCAN_SECS) {
/* time to scan */
- (void)maildir_tmp_cleanup(storage, path);
+ (void)unlink_old_files(path, "",
+ ioloop_time - MAILDIR_TMP_DELETE_SECS);
}
return 1;
}
diff -r d421f14ba797 -r 7ae8505870c1 src/lib-storage/index/maildir/maildir-storage.h
--- a/src/lib-storage/index/maildir/maildir-storage.h Sat Dec 08 17:05:17 2007 +0200
+++ b/src/lib-storage/index/maildir/maildir-storage.h Sat Dec 08 17:10:18 2007 +0200
@@ -120,7 +120,6 @@ int maildir_file_do(struct maildir_mailb
maildir_file_do(mbox, seq, (maildir_file_do_func *)callback, context)
#endif
-void maildir_tmp_cleanup(struct mail_storage *storage, const char *dir);
bool maildir_set_deleted(struct maildir_mailbox *mbox);
void maildir_transaction_class_init(void);
diff -r d421f14ba797 -r 7ae8505870c1 src/lib-storage/index/maildir/maildir-util.c
--- a/src/lib-storage/index/maildir/maildir-util.c Sat Dec 08 17:05:17 2007 +0200
+++ b/src/lib-storage/index/maildir/maildir-util.c Sat Dec 08 17:10:18 2007 +0200
@@ -88,84 +88,6 @@ int maildir_file_do(struct maildir_mailb
return ret == -2 ? 0 : ret;
}
-static void
-maildir_tmp_cleanup_real(struct mail_storage *storage, const char *dir)
-{
- DIR *dirp;
- struct dirent *d;
- struct stat st;
- string_t *path;
- unsigned int dir_len;
-
- dirp = opendir(dir);
- if (dirp == NULL) {
- if (errno != ENOENT) {
- mail_storage_set_critical(storage,
- "opendir(%s) failed: %m", dir);
- }
- return;
- }
-
- path = t_str_new(256);
- str_printfa(path, "%s/", dir);
- dir_len = str_len(path);
-
- while ((d = readdir(dirp)) != NULL) {
- if (d->d_name[0] == '.' &&
- (d->d_name[1] == '\0' ||
- (d->d_name[1] == '.' && d->d_name[2] == '\0'))) {
- /* skip . and .. */
- continue;
- }
-
- str_truncate(path, dir_len);
- str_append(path, d->d_name);
- if (stat(str_c(path), &st) < 0) {
- if (errno != ENOENT) {
- mail_storage_set_critical(storage,
- "stat(%s) failed: %m", str_c(path));
- }
- } else if (st.st_ctime <=
- ioloop_time - MAILDIR_TMP_DELETE_SECS) {
- if (unlink(str_c(path)) < 0 && errno != ENOENT) {
- mail_storage_set_critical(storage,
- "unlink(%s) failed: %m", str_c(path));
- }
- }
- }
-
-#ifdef HAVE_DIRFD
- if (fstat(dirfd(dirp), &st) < 0) {
- mail_storage_set_critical(storage,
- "fstat(%s) failed: %m", dir);
- }
-#else
- if (stat(dir, &st) < 0) {
- mail_storage_set_critical(storage,
- "stat(%s) failed: %m", dir);
- }
-#endif
- else if (st.st_atime < ioloop_time) {
- /* mounted with noatime. update it ourself. */
- if (utime(dir, NULL) < 0 && errno != ENOENT) {
- mail_storage_set_critical(storage,
- "utime(%s) failed: %m", dir);
- }
- }
-
- if (closedir(dirp) < 0) {
- mail_storage_set_critical(storage,
- "closedir(%s) failed: %m", dir);
- }
-}
-
-void maildir_tmp_cleanup(struct mail_storage *storage, const char *dir)
-{
- T_FRAME(
- maildir_tmp_cleanup_real(storage, dir);
- );
-}
-
static int maildir_create_subdirs(struct maildir_mailbox *mbox)
{
static const char *subdirs[] = { "cur", "new", "tmp" };
More information about the dovecot-cvs
mailing list