Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6958:7ae8505870c1 HEAD
Removed maildir_tmp_cleanup(). Use unlink_old_files() instead.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 08 Dec 2007 17:10:18 +0200 |
parents | d421f14ba797 |
children | a1e271317eb2 |
files | src/lib-storage/index/maildir/maildir-storage.c src/lib-storage/index/maildir/maildir-storage.h src/lib-storage/index/maildir/maildir-util.c |
diffstat | 3 files changed, 4 insertions(+), 80 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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; }
--- 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 @@ 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);
--- 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 @@ 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" };