struct index_mail_data *data = &mail->data;
struct stat st;
- if (index_mail_get_save_date(_mail, date_r) == 0)
- return 0;
+ if (index_mail_get_save_date(_mail, date_r) > 0)
+ return 1;
if (cydir_mail_stat(_mail, &st) < 0)
return -1;
data->save_date = st.st_ctime;
*date_r = data->save_date;
- return 0;
+ return 1;
}
static int cydir_mail_get_physical_size(struct mail *_mail, uoff_t *size_r)
struct stat st;
uoff_t offset;
- if (index_mail_get_save_date(_mail, date_r) == 0)
- return 0;
+ if (index_mail_get_save_date(_mail, date_r) > 0)
+ return 1;
if (storage->v.mail_open(mail, &offset, &file) < 0)
return -1;
return -1;
}
*date_r = data->save_date = st.st_ctime;
- return 0;
+ return 1;
}
static int
}
*date_r = dbox_rec->save_date;
- return 0;
+ return 1;
}
static int
if (data->save_date == (time_t)-1) {
/* FIXME: we could use a value stored in cache */
- return imapc_mail_get_received_date(_mail, date_r);
+ if (imapc_mail_get_received_date(_mail, date_r) < 0)
+ return -1;
+ return 0;
}
*date_r = data->save_date;
return 0;
}
*date_r = data->save_date;
- return *date_r == (time_t)-1 ? -1 : 0;
+ return *date_r == (time_t)-1 ? -1 : 1;
}
static int index_mail_cache_sent_date(struct index_mail *mail)
mail = mail_alloc(t, 0, NULL);
for (seq = 1; seq <= hdr->messages_count; seq++) {
mail_set_seq(mail, seq);
- if (mail_get_save_date(mail, &metadata_r->first_save_date) == 0) {
+ if (mail_get_save_date(mail, &metadata_r->first_save_date) >= 0) {
ret = 0;
break;
}
struct index_mail_data *data = &mail->data;
struct stat st;
- if (index_mail_get_save_date(_mail, date_r) == 0)
- return 0;
+ if (index_mail_get_save_date(_mail, date_r) > 0)
+ return 1;
if (maildir_mail_stat(_mail, &st) < 0)
return -1;
*date_r = data->save_date = st.st_ctime;
- return 0;
+ return 1;
}
static int
struct index_mail *mail = INDEX_MAIL(_mail);
struct index_mail_data *data = &mail->data;
- if (index_mail_get_save_date(_mail, date_r) == 0)
+ if (index_mail_get_save_date(_mail, date_r) > 0)
return 0;
/* no way to know this. save the current time into cache and use
if (data->save_date == (time_t)-1) {
/* FIXME: we could use a value stored in cache */
- return pop3c_mail_get_received_date(_mail, date_r);
+ if (pop3c_mail_get_received_date(_mail, date_r) < 0)
+ return -1;
+ return 0;
}
*date_r = data->save_date;
return 0;
}
*date_r = mail->data.save_date = mbox->ctime;
- return 0;
+ return 1;
}
static int raw_mail_get_physical_size(struct mail *_mail, uoff_t *size_r)
messages_count = mail_index_view_get_messages_count(box->view);
for (seq = 1; seq <= messages_count; seq++) {
mail_set_seq(mail, seq);
- if (mail_get_save_date(mail, &save_date) == 0) {
+ if (mail_get_save_date(mail, &save_date) >= 0) {
first_saved.uid = mail->uid;
first_saved.timestamp = save_date;
break;
/* only max_mails is used. nothing further to do. */
done = TRUE;
break;
- } else if (mail_get_save_date(mail, ×tamp) == 0) {
+ } else if (mail_get_save_date(mail, ×tamp) >= 0) {
if (I_MAX(last_rename_stamp, timestamp) > expire_time) {
done = TRUE;
break;
int mail_get_date(struct mail *mail, time_t *date_r, int *timezone_r);
/* Get the time when the mail was received (IMAP INTERNALDATE). */
int mail_get_received_date(struct mail *mail, time_t *date_r);
-/* Get the time when the mail was saved into this mailbox. This time may not
- always be entirely reliable. */
+/* Get the time when the mail was saved into this mailbox. This returns -1 on
+ error, 0 if a real save date is not supported and a fall-back date is used,
+ and 1 when a save date was successfully retrieved. */
int mail_get_save_date(struct mail *mail, time_t *date_r);
/* Get the space used by the mail as seen by the reader. Linefeeds are always
for (seq = 2; seq <= hdr->messages_count; seq++) {
if (!mail_index_is_expunged(view, seq)) {
mail_set_seq(mail, seq);
- if (mail_get_save_date(mail, stamp_r) == 0)
+ if (mail_get_save_date(mail, stamp_r) >= 0)
break;
}
}
{
struct virtual_mail *vmail = (struct virtual_mail *)mail;
struct mail *backend_mail;
+ int ret;
if (backend_mail_get(vmail, &backend_mail) < 0)
return -1;
- if (mail_get_save_date(backend_mail, date_r) < 0) {
+ ret = mail_get_save_date(backend_mail, date_r);
+ if (ret < 0)
virtual_box_copy_error(mail->box, backend_mail->box);
- return -1;
- }
- return 0;
+ return ret;
}
static int virtual_mail_get_virtual_mail_size(struct mail *mail, uoff_t *size_r)