-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the completed field from upload and refactor serializer
[noissue]
- Loading branch information
1 parent
95e5130
commit cf5bada
Showing
12 changed files
with
38 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Allow users to pass sha256 with each chunk to have Pulp verify the chunk. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Have the commit endpoint dispatch a task to create artifacts from chunked uploads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Removed upload parameter from artifact create endpoint and converted upload commit to return 202. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Users can view chunks info for chunked uploads in the API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 2.2.3 on 2019-07-24 17:28 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0002_increase_artifact_size_field'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='upload', | ||
name='completed', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,35 @@ | ||
from datetime import datetime | ||
from gettext import gettext as _ | ||
from logging import getLogger | ||
|
||
from rest_framework import serializers | ||
|
||
from pulpcore.app import models | ||
from pulpcore.app import files, models | ||
from pulpcore.app.models import CreatedResource | ||
from pulpcore.app.serializers import ArtifactUploadSerializer | ||
from pulpcore.tasking.util import get_url | ||
from pulpcore.app.serializers import ArtifactSerializer | ||
|
||
log = getLogger(__name__) | ||
|
||
|
||
def commit(upload_id, sha256): | ||
""" | ||
Commit the upload and mark it as completed. | ||
Commit a :class:`~pulpcore.app.models.Upload` | ||
Commit the upload and turn it into an artifact. | ||
Args: | ||
upload_id (int): The upload primary key | ||
sha256 (str): The checksum for the uploaded file | ||
""" | ||
try: | ||
upload = models.Upload.objects.get(pk=upload_id) | ||
except models.Upload.DoesNotExist: | ||
log.info(_('The upload was not found. Nothing to do.')) | ||
return | ||
|
||
log.info(_('Commiting the upload %(i)d and mark it as completed'), {'i': upload_id}) | ||
|
||
if not sha256: | ||
raise serializers.ValidationError(_("Checksum not supplied.")) | ||
|
||
upload.completed = datetime.now() | ||
upload.save() | ||
|
||
data = {'upload': get_url(upload), 'sha256': sha256} | ||
serializer = ArtifactUploadSerializer(data=data) | ||
file = files.PulpTemporaryUploadedFile.from_file(upload.file.file) | ||
data = {'file': file, 'sha256': sha256} | ||
serializer = ArtifactSerializer(data=data) | ||
serializer.is_valid(raise_exception=True) | ||
artifact = serializer.save() | ||
|
||
resource = CreatedResource(content_object=artifact) | ||
resource.save() | ||
|
||
# delete the upload since it can't be reused to create another artifact | ||
upload.delete() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters