Exemple #1
0
def download_and_commit_uids(crispin_client, db_session, log, folder_name,
                             uids, msg_create_fn, syncmanager_lock):
    raw_messages = safe_download(crispin_client, log, uids)
    with syncmanager_lock:
        log.debug("download_and_commit_uids acquired syncmanager_lock")
        new_imapuids = create_db_objects(crispin_client.account_id, db_session,
                                         log, folder_name, raw_messages,
                                         msg_create_fn)
        commit_uids(db_session, log, new_imapuids)
    return len(new_imapuids)
Exemple #2
0
def download_and_commit_uids(crispin_client, log, folder_name, uids,
                             msg_create_fn, syncmanager_lock):
    raw_messages = safe_download(crispin_client, log, uids)
    with syncmanager_lock:
        log.debug("download_and_commit_uids acquired syncmanager_lock")
        with session_scope(ignore_soft_deletes=False) as db_session:
            new_imapuids = create_db_objects(crispin_client.account_id,
                                             db_session, log, folder_name,
                                             raw_messages, msg_create_fn)
            commit_uids(db_session, log, new_imapuids)
    return len(new_imapuids)
Exemple #3
0
 def download_and_commit_uids(self, crispin_client, folder_name, uids):
     # Note that folder_name here might *NOT* be equal to self.folder_name,
     # because, for example, we download messages via the 'All Mail' folder
     # in Gmail.
     raw_messages = safe_download(crispin_client, uids)
     with self.syncmanager_lock:
         with mailsync_session_scope() as db_session:
             new_imapuids = create_db_objects(
                 self.account_id, db_session, log, folder_name,
                 raw_messages, self.create_message)
             commit_uids(db_session, log, new_imapuids)
     return len(new_imapuids)
Exemple #4
0
 def download_and_commit_uids(self, crispin_client, folder_name, uids):
     # Note that folder_name here might *NOT* be equal to self.folder_name,
     # because, for example, we download messages via the 'All Mail' folder
     # in Gmail.
     raw_messages = safe_download(crispin_client, uids)
     with self.syncmanager_lock:
         with mailsync_session_scope() as db_session:
             new_imapuids = create_db_objects(self.account_id, db_session,
                                              log, folder_name,
                                              raw_messages,
                                              self.create_message)
             commit_uids(db_session, log, new_imapuids)
     return len(new_imapuids)
Exemple #5
0
 def download_and_commit_uids(self, crispin_client, folder_name, uids):
     raw_messages = safe_download(crispin_client, uids)
     with self.syncmanager_lock:
         # there is the possibility that another green thread has already
         # downloaded some message(s) from this batch... check within the
         # lock
         with mailsync_session_scope() as db_session:
             raw_messages = self.__deduplicate_message_object_creation(
                 db_session, raw_messages)
             if not raw_messages:
                 return 0
             new_imapuids = create_db_objects(
                 self.account_id, db_session, log, folder_name,
                 raw_messages, self.create_message)
             commit_uids(db_session, new_imapuids)
     return len(new_imapuids)
Exemple #6
0
 def download_and_commit_uids(self, crispin_client, folder_name, uids):
     raw_messages = safe_download(crispin_client, uids)
     with self.syncmanager_lock:
         # there is the possibility that another green thread has already
         # downloaded some message(s) from this batch... check within the
         # lock
         with mailsync_session_scope() as db_session:
             raw_messages = self.__deduplicate_message_object_creation(
                 db_session, raw_messages)
             if not raw_messages:
                 return 0
             new_imapuids = create_db_objects(
                 self.account_id, db_session, log, folder_name,
                 raw_messages, self.create_message)
             commit_uids(db_session, new_imapuids, self.provider_name)
     self.saved_uids.update(uids)
     return len(new_imapuids)
Exemple #7
0
def gmail_download_and_commit_uids(crispin_client, db_session, log,
                                   folder_name, uids, msg_create_fn,
                                   syncmanager_lock):
    log.debug('downloading uids', uids=uids)
    raw_messages = safe_download(crispin_client, log, uids)
    with syncmanager_lock:
        log.debug('gmail_download_and_commit_uids acquired syncmanager_lock')
        # there is the possibility that another green thread has already
        # downloaded some message(s) from this batch... check within the lock
        raw_messages = deduplicate_message_object_creation(
            crispin_client.account_id, db_session, log, raw_messages)
        log.debug(unsaved_message_object_count=len(raw_messages))
        new_imapuids = create_db_objects(crispin_client.account_id, db_session,
                                         log, folder_name, raw_messages,
                                         msg_create_fn)
        commit_uids(db_session, log, new_imapuids)
        log.debug(new_committed_message_count=len(new_imapuids))
    return len(new_imapuids)
Exemple #8
0
def gmail_download_and_commit_uids(crispin_client, log, folder_name, uids,
                                   msg_create_fn, syncmanager_lock):
    log.info('downloading uids', uids=uids)
    raw_messages = safe_download(crispin_client, log, uids)
    with syncmanager_lock:
        log.debug('gmail_download_and_commit_uids acquired syncmanager_lock')
        # there is the possibility that another green thread has already
        # downloaded some message(s) from this batch... check within the lock
        with session_scope(ignore_soft_deletes=False) as db_session:
            raw_messages = deduplicate_message_object_creation(
                crispin_client.account_id, db_session, log, raw_messages)
            if not raw_messages:
                return 0
            new_imapuids = create_db_objects(
                crispin_client.account_id, db_session, log, folder_name,
                raw_messages, msg_create_fn)
            commit_uids(db_session, log, new_imapuids)
            log.info(new_committed_message_count=len(new_imapuids))
    return len(new_imapuids)