mail-index-view-sync.c revision 882fd2a050eff86d740f5e5b9fc2fc4f21ed3734
0N/A/* Copyright (c) 2003-2011 Dovecot authors, see the included COPYING file */ 0N/A /* After syncing view, map is replaced with sync_new_map. */ 0N/A /* temporary variables while handling lost transaction logs: */ 0N/A /* result of lost transaction logs: */ 975N/A "%s log position went backwards " 975N/A /* the view begins from the first non-synced transaction */ 975N/A /* log was reset, but we don't want to sync expunges. 975N/A we can't do this, so sync only up to the reset. */ 975N/A /* we have only this reset log */ 975N/A /* convert UIDs to sequences */ 984N/A /* get a list of expunge transactions. there may be some that we have 984N/A already synced, but it doesn't matter because they'll get dropped 975N/A out when converting to sequences. the uid ranges' validity has 984N/A already been verified, so we can use them directly. */ 984N/A /* skip expunge requests */ 0N/A /* skip expunge requests */ 116N/A /* we have an expunge. see if it still exists. */ 979N/A /* we have an expunge. see if it still exists. */ 979N/A /* handle failures as having expunges (which is safer). 116N/A we'll probably fail later. */ 863N/A /* add new flags one by one */ 975N/A /* check this before syncing the record, since it updates 979N/A /* remove all old flags by resetting them */ 979N/A /* flags or keywords changed */ 979N/A /* if modseq has changed include this message in changed flags 979N/A list, even if we didn't see any changes above. */ 295N/A /* without modseqs lost_flags isn't updated perfectly correctly, because 295N/A by the time we're comparing old flags it may have changed from what 295N/A we last sent to the client (because the map is shared). This could 341N/A be avoided by always keeping a private copy of the map in the view, 295N/A but that's a waste of memory for as rare of a problem as this. */ 341N/A /* we don't update the map in the same order as it's typically done. 341N/A map->rec_map may already have some messages appended that we don't 341N/A want. get an atomic map to make sure these get removed. */ 301N/A /* handle expunges and sync flags */ 301N/A /* message found - check if flags have changed */ 301N/A /* new message appeared out of nowhere */ 301N/A "%s view is inconsistent: " 301N/A "uid=%u inserted in the middle of mailbox",
301N/A /* if there are old messages left, they're all expunged */ 301N/A /* if there are new messages left, they're all new messages */ 576N/A /* we have no idea how far we've synced - make sure these aren't used */ 379N/A /* replace the view's map */ 411N/A /* Syncing the view invalidates all previous looked up records. 411N/A Unreference the mappings this view keeps because of them. */ 411N/A /* just get this view synced - don't return anything */ 624N/A "%s view syncing failed to apply changes",
624N/A /* get list of all expunges first */ "%s reset, view is now inconsistent",
/* no expunges, we can just replace the map */ "Index %s lost messages without expunging " /* expunges seen. create a private map which we update. if we're syncing expunges the map will finally be replaced with the head map to remove the expunged messages. */ /* Get the next transaction from log. */ /* skip records we've already synced */ /* If we started from a map that we didn't create ourself, some of the transactions may already be synced. at the end of this view sync we'll update file_seq=0 so that this check always becomes FALSE for subsequent syncs. */ /* Apply transaction to view's mapping if needed (meaning we didn't just re-map the view to head mapping). */ /* data contains mail_transaction_flag_update[] */ /* skip internal flag changes */ /* data contains mail_transaction_keyword_update header, the keyword name and an array of { uint32_t uid1, uid2; } */ /* skip over the header and name */ /* data contains mail_transaction_keyword_reset[] */ /* Clean up to view's tail */ for (i = 0; i <
count; i++) {
/* we didn't sync everything */ /* log offsets have no meaning in views. make sure they're not tried to be used wrong by setting them to zero. */ /* set log view to empty range so unneeded memory gets freed */