def update_metadata(crispin_client, db_session, log, folder_name, uids, syncmanager_lock): """ Update flags (the only metadata that can change). """ # bigger chunk because the data being fetched here is very small for uids in chunk(uids, 5 * crispin_client.CHUNK_SIZE): new_flags = crispin_client.flags(uids) assert sorted(uids, key=int) == sorted(new_flags.keys(), key=int), \ "server uids != local uids" log.info("new flags: {0}".format(new_flags)) with syncmanager_lock: log.debug("update_metadata acquired syncmanager_lock") account.update_metadata(crispin_client.account_id, db_session, folder_name, uids, new_flags) db_session.commit()
def update_metadata(crispin_client, db_session, log, folder_name, uids, syncmanager_lock): """ Update flags (the only metadata that can change). """ # bigger chunk because the data being fetched here is very small for uids in chunk(uids, 5 * crispin_client.CHUNK_SIZE): new_flags = crispin_client.flags(uids) # messages can disappear in the meantime; we'll update them next sync uids = [uid for uid in uids if uid in new_flags] log.info("new flags ", new_flags=new_flags, folder_name=folder_name) with syncmanager_lock: log.debug("update_metadata acquired syncmanager_lock") account.update_metadata(crispin_client.account_id, db_session, folder_name, uids, new_flags) db_session.commit()
def update_metadata(crispin_client, log, folder_name, uids, syncmanager_lock): """ Update flags (the only metadata that can change). """ # bigger chunk because the data being fetched here is very small for uids in chunk(uids, 5 * crispin_client.CHUNK_SIZE): new_flags = crispin_client.flags(uids) # messages can disappear in the meantime; we'll update them next sync uids = [uid for uid in uids if uid in new_flags] log.info("new flags ", new_flags=new_flags, folder_name=folder_name) with syncmanager_lock: log.debug("update_metadata acquired syncmanager_lock") with session_scope(ignore_soft_deletes=False) as db_session: account.update_metadata(crispin_client.account_id, db_session, folder_name, uids, new_flags) db_session.commit()