Handle the common case of one chunk when calculating the uncompressed size
Reference #992
This commit is contained in:
parent
1323da20e3
commit
54095eb5cb
6 changed files with 65 additions and 4 deletions
|
@ -784,6 +784,8 @@ class BlobUpload(BaseModel):
|
|||
sha_state = ResumableSHAField(null=True, default=resumablehashlib.sha256)
|
||||
location = ForeignKeyField(ImageStorageLocation)
|
||||
storage_metadata = JSONField(null=True, default={})
|
||||
chunk_count = IntegerField(default=0)
|
||||
uncompressed_byte_count = IntegerField(null=True)
|
||||
|
||||
class Meta:
|
||||
database = db
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
"""Add new blobupload columns
|
||||
|
||||
Revision ID: 403d02fea323
|
||||
Revises: 10b999e8db1f
|
||||
Create Date: 2015-11-30 14:25:46.822730
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '403d02fea323'
|
||||
down_revision = '10b999e8db1f'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
def upgrade(tables):
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('blobupload', sa.Column('chunk_count', sa.Integer(), nullable=False))
|
||||
op.add_column('blobupload', sa.Column('uncompressed_byte_count', sa.Integer(), nullable=True))
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade(tables):
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('blobupload', 'uncompressed_byte_count')
|
||||
op.drop_column('blobupload', 'chunk_count')
|
||||
### end Alembic commands ###
|
|
@ -26,7 +26,7 @@ def get_repo_blob_by_digest(namespace, repo_name, blob_digest):
|
|||
|
||||
|
||||
def store_blob_record_and_temp_link(namespace, repo_name, blob_digest, location_obj, byte_count,
|
||||
link_expiration_s):
|
||||
link_expiration_s, uncompressed_byte_count=None):
|
||||
""" Store a record of the blob and temporarily link it to the specified repository.
|
||||
"""
|
||||
random_image_name = str(uuid4())
|
||||
|
@ -35,6 +35,7 @@ def store_blob_record_and_temp_link(namespace, repo_name, blob_digest, location_
|
|||
try:
|
||||
storage = ImageStorage.get(content_checksum=blob_digest)
|
||||
storage.image_size = byte_count
|
||||
storage.uncompressed_size = uncompressed_byte_count
|
||||
storage.save()
|
||||
|
||||
ImageStoragePlacement.get(storage=storage, location=location_obj)
|
||||
|
|
Reference in a new issue