def update_blob_upload( self, blob_upload, uncompressed_byte_count, piece_hashes, piece_sha_state, storage_metadata, byte_count, chunk_count, sha_state, ): """ Updates the fields of the blob upload to match those given. Returns the updated blob upload or None if the record does not exists. """ upload_record = model.blob.get_blob_upload_by_uuid( blob_upload.upload_id) if upload_record is None: return None upload_record.uncompressed_byte_count = uncompressed_byte_count upload_record.piece_hashes = piece_hashes upload_record.piece_sha_state = piece_sha_state upload_record.storage_metadata = storage_metadata upload_record.byte_count = byte_count upload_record.chunk_count = chunk_count upload_record.sha_state = sha_state upload_record.save() return BlobUpload.for_upload(upload_record)
def lookup_blob_upload(self, repository_ref, blob_upload_id): """ Looks up the blob upload withn the given ID under the specified repository and returns it or None if none. """ upload_record = model.blob.get_blob_upload_by_uuid(blob_upload_id) if upload_record is None: return None return BlobUpload.for_upload(upload_record)
def create_blob_upload(self, repository_ref, new_upload_id, location_name, storage_metadata): """ Creates a new blob upload and returns a reference. If the blob upload could not be created, returns None. """ repo = model.repository.lookup_repository(repository_ref._db_id) if repo is None: return None try: upload_record = model.blob.initiate_upload_for_repo( repo, new_upload_id, location_name, storage_metadata) return BlobUpload.for_upload(upload_record, location_name=location_name) except database.Repository.DoesNotExist: return None