]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Added mail_index_get_modification_time().
authorTimo Sirainen <tss@iki.fi>
Mon, 15 Feb 2010 02:29:47 +0000 (04:29 +0200)
committerTimo Sirainen <tss@iki.fi>
Mon, 15 Feb 2010 02:29:47 +0000 (04:29 +0200)
--HG--
branch : HEAD

src/lib-index/mail-index.c
src/lib-index/mail-index.h
src/lib-index/mail-transaction-log.c
src/lib-index/mail-transaction-log.h

index 0a6e69e84b9c208a5ac8c18d08ccd949016e2520..b41376be16fa61cbbbdaf5a2af416988d26f8730 100644 (file)
@@ -751,6 +751,23 @@ bool mail_index_is_deleted(struct mail_index *index)
        return index->index_delete_requested || index->index_deleted;
 }
 
+int mail_index_get_modification_time(struct mail_index *index, time_t *mtime_r)
+{
+       struct stat st;
+
+       if (mail_transaction_log_get_mtime(index->log, mtime_r) < 0)
+               return -1;
+
+       if (*mtime_r == 0) {
+               if (stat(index->filepath, &st) < 0) {
+                       mail_index_set_syscall_error(index, "stat()");
+                       return -1;
+               }
+               *mtime_r = st.st_mtime;
+       }
+       return 0;
+}
+
 void mail_index_fchown(struct mail_index *index, int fd, const char *path)
 {
        mode_t mode;
index 41fc63014e814443c71fbc448f268df2fe7ccf7b..2bf75b0c567c510074d8ee2d1112e0e314af1253 100644 (file)
@@ -456,6 +456,8 @@ void mail_index_set_undeleted(struct mail_index_transaction *t);
 /* Returns TRUE if index has been set deleted. This gets set only after
    index has been opened/refreshed and the transaction has been seen. */
 bool mail_index_is_deleted(struct mail_index *index);
+/* Returns the last time mailbox was modified. */
+int mail_index_get_modification_time(struct mail_index *index, time_t *mtime_r);
 
 /* Lookup a keyword, returns TRUE if found, FALSE if not. */
 bool mail_index_keyword_lookup(struct mail_index *index,
index d630817a3ef4107aa071abc1a2e0f735fca3575a..a4477abc7fe44d67683a07cb4dbaa27963b19dec 100644 (file)
@@ -509,3 +509,21 @@ bool mail_transaction_log_is_head_prev(struct mail_transaction_log *log,
        return log->head->hdr.prev_file_seq == file_seq &&
                log->head->hdr.prev_file_offset == file_offset;
 }
+
+int mail_transaction_log_get_mtime(struct mail_transaction_log *log,
+                                  time_t *mtime_r)
+{
+       struct stat st;
+
+       *mtime_r = 0;
+       if (stat(log->filepath, &st) < 0) {
+               if (errno == ENOENT)
+                       return 0;
+
+               mail_index_file_set_syscall_error(log->index, log->filepath,
+                                                 "stat()");
+               return -1;
+       }
+       *mtime_r = st.st_mtime;
+       return 0;
+}
index 686b24cb5343568f183f9471d420f7620012e460..a633db76fe8077d3d3090daf328d6c04d24ff0e2 100644 (file)
@@ -280,5 +280,9 @@ bool mail_transaction_log_is_head_prev(struct mail_transaction_log *log,
 /* Move currently opened log head file to memory (called by
    mail_index_move_to_memory()) */
 void mail_transaction_log_move_to_memory(struct mail_transaction_log *log);
+/* Returns mtime of the transaction log head file.
+   If it doesn't exist, mtime_r is set to 0. */
+int mail_transaction_log_get_mtime(struct mail_transaction_log *log,
+                                  time_t *mtime_r);
 
 #endif