Beispiel #1
0
 def delete(self, deletes, force=False):
     _deletes = ', '.join([delete.id for delete in deletes])
     if not force:
         logger.info(
             'Would have deleted credential and revisions: {}'.format(
                 _deletes, ))
         return
     logger.info('Deleting credential and revisions: {}'.format(_deletes, ))
     with Credential.batch_write() as batch:
         for delete in deletes:
             batch.delete(delete)
     stats.incr('archive.delete.success')
Beispiel #2
0
 def save(self, saves, force=False):
     # Do not restore a credential if it exists in the primary table.
     # We do this check at the point of all saves so that we can
     # restore revisions, if one of them failed to restore for some
     # reason.
     _saves = []
     for save in saves:
         if self.credential_exists(save.id):
             continue
         _saves.append(save)
     if not _saves:
         return
     save_msg = ', '.join([save.id for save in _saves])
     if not force:
         logger.info(
             'Would have restored credential and revisions: {}'.format(
                 save_msg, ))
         return
     logger.info('Restoring credential and revisions: {}'.format(
         save_msg, ))
     with Credential.batch_write() as batch:
         for save in _saves:
             batch.save(save)
     stats.incr('restore.save.success')