def already_uploaded(instance, binlog, logged_uploads):
""" Check to see if a binlog has already been uploaded
Args:
instance - a hostAddr object
binlog - the full path to the binlog file
logged_uploads - a set of all uploaded binlogs for this instance
Returns True if already uplaoded, False otherwise.
"""
if os.path.basename(binlog) in logged_uploads:
log.debug('Binlog already logged as uploaded')
return True
# we should hit this code rarely, only when uploads have not been logged
boto_conn = boto.connect_s3()
bucket = boto_conn.get_bucket(S3_BINLOG_BUCKET, validate=False)
if bucket.get_key(s3_binlog_path(instance, os.path.basename((binlog)))):
log.debug("Binlog already uploaded but not logged {b}".format(
b=binlog))
log_binlog_upload(instance, binlog)
return True
return False
评论列表
文章目录