def highestmodseq_update( crispin_client, db_session, log, folder_name, last_highestmodseq, status_cb, highestmodseq_fn, syncmanager_lock, c ): account_id = crispin_client.account_id new_highestmodseq = crispin_client.selected_highestmodseq new_uidvalidity = crispin_client.selected_uidvalidity log.info("Starting highestmodseq update on {0} (current HIGHESTMODSEQ: {1})".format(folder_name, new_highestmodseq)) local_uids = account.all_uids(account_id, db_session, folder_name) changed_uids = crispin_client.new_and_updated_uids(last_highestmodseq, c) remote_uids = crispin_client.all_uids(c) if changed_uids: new, updated = new_or_updated(changed_uids, local_uids) log.info("{0} new and {1} updated UIDs".format(len(new), len(updated))) local_uids += new deleted_uids = remove_deleted_uids( account_id, db_session, log, folder_name, local_uids, remote_uids, syncmanager_lock, c ) local_uids = set(local_uids) - deleted_uids update_metadata(crispin_client, db_session, log, folder_name, updated, syncmanager_lock, c) highestmodseq_fn( crispin_client, db_session, log, folder_name, changed_uids, local_uids, status_cb, syncmanager_lock, c ) else: log.info("No new or updated messages") remove_deleted_uids( crispin_client.account_id, db_session, log, folder_name, local_uids, remote_uids, syncmanager_lock, c ) account.update_uidvalidity(account_id, db_session, folder_name, new_uidvalidity, new_highestmodseq) db_session.commit()
def get_g_metadata(crispin_client, db_session, log, folder_name, uids, syncmanager_lock): assert folder_name == crispin_client.selected_folder_name, \ "crispin selected folder isn't as expected" account_id = crispin_client.account_id remote_g_metadata = None saved_validity = account.get_uidvalidity(account_id, db_session, folder_name) if saved_validity is not None: # If there's no cached validity we probably haven't run before. remote_g_metadata = retrieve_saved_g_metadata(crispin_client, db_session, log, folder_name, uids, saved_validity, syncmanager_lock) if remote_g_metadata is None: remote_g_metadata = crispin_client.g_metadata( crispin_client.all_uids()) set_cache(remote_g_metadata_cache_file(account_id, folder_name), remote_g_metadata) # Save highestmodseq that corresponds to the saved g_metadata. account.update_uidvalidity(account_id, db_session, folder_name, crispin_client.selected_uidvalidity, crispin_client.selected_highestmodseq) db_session.commit() return remote_g_metadata
def get_g_metadata(crispin_client, db_session, log, folder_name, uids, syncmanager_lock): assert folder_name == crispin_client.selected_folder_name, \ "crispin selected folder isn't as expected" account_id = crispin_client.account_id remote_g_metadata = None saved_validity = account.get_uidvalidity(account_id, db_session, folder_name) if saved_validity is not None: # If there's no cached validity we probably haven't run before. remote_g_metadata = retrieve_saved_g_metadata(crispin_client, db_session, log, folder_name, uids, saved_validity, syncmanager_lock) if remote_g_metadata is None: remote_g_metadata = crispin_client.g_metadata( crispin_client.all_uids()) set_cache(remote_g_metadata_cache_file(account_id, folder_name), remote_g_metadata) # Save highestmodseq that corresponds to the saved g_metadata. account.update_uidvalidity(account_id, db_session, folder_name, crispin_client.selected_uidvalidity, crispin_client.selected_highestmodseq) db_session.commit() return remote_g_metadata