Skip to content

Commit

Permalink
index-storage: Update mailbox last_rename_stamp on rename
Browse files Browse the repository at this point in the history
  • Loading branch information
cmouse authored and sirainen committed Jan 9, 2017
1 parent 34f7cc3 commit b88c159
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/lib-storage/index/index-storage.c
Expand Up @@ -299,6 +299,10 @@ int index_storage_mailbox_open(struct mailbox *box, bool move_to_memory)
box->box_name_hdr_ext_id =
mail_index_ext_register(box->index, "box-name", 0, 0, 0);

box->box_last_rename_stamp_ext_id =
mail_index_ext_register(box->index, "last-rename-stamp",
sizeof(uint32_t), 0, sizeof(uint32_t));

box->opened = TRUE;

if ((box->enabled_features & MAILBOX_FEATURE_CONDSTORE) != 0)
Expand Down Expand Up @@ -794,6 +798,19 @@ int index_storage_mailbox_rename(struct mailbox *src, struct mailbox *dest)
return -1;
}

if (mailbox_open(dest) == 0) {
struct mail_index_transaction *t =
mail_index_transaction_begin(dest->view, 0);

uint32_t stamp = ioloop_time;

mail_index_update_header_ext(t, dest->box_last_rename_stamp_ext_id,
0, &stamp, sizeof(stamp));

/* can't do much if this fails anyways */
(void)mail_index_transaction_commit(&t);
}

/* we'll track mailbox names, instead of GUIDs. We may be renaming a
non-selectable mailbox (directory), which doesn't even have a GUID */
mailbox_name_get_sha128(dest->vname, guid);
Expand Down
1 change: 1 addition & 0 deletions src/lib-storage/mail-storage-private.h
Expand Up @@ -361,6 +361,7 @@ struct mailbox {
uint32_t vsize_hdr_ext_id;
uint32_t pop3_uidl_hdr_ext_id;
uint32_t box_name_hdr_ext_id;
uint32_t box_last_rename_stamp_ext_id;

/* MAIL_RECENT flags handling */
ARRAY_TYPE(seq_range) recent_flags;
Expand Down

0 comments on commit b88c159

Please sign in to comment.