Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including file type extension #294

Merged
merged 1 commit into from
Mar 6, 2020
Merged

Including file type extension #294

merged 1 commit into from
Mar 6, 2020

Conversation

fao89
Copy link
Member

@fao89 fao89 commented Mar 4, 2020

@fao89 fao89 requested a review from bmbouter March 4, 2020 21:09
@@ -0,0 +1 @@
Including file type extension
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this call out the upload case as when the user would experience it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure!

@@ -157,8 +157,10 @@ def post(self, request, path):
artifact = Artifact.init_and_validate(serializer.validated_data["file"])
artifact.save()

filename = serializer.validated_data["file"].name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the concerns is about falsified content so we can't rely on this user provided data. We can rely that the name should always be namespace-name-version.tar.gz like the example here https://docs.ansible.com/ansible/latest/user_guide/collections_using.html#id2

Maybe we need another helper function like this one? https://github.com/pulp/pulp_ansible/blob/master/pulp_ansible/app/models.py#L166 but for the filename generation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the extension will always be tar.gz?

@@ -169,9 +171,7 @@ def import_collection(
collection_version.save() # Save the FK updates

ContentArtifact.objects.create(
artifact=artifact,
content=collection_version,
relative_path=collection_version.relative_path,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it is always tar.gz
we only have to do:

relative_path=f"{collection_version.relative_path}.tar.gz",

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the solution I had in mind rather that using the filename of the file uploaded by the user.

Copy link
Contributor

@daviddavis daviddavis Mar 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the relative_path property on CollectionVersion is only used here. Seems like we should probably update it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also thinking this. To check if it's safe is it used elsewhere in the code at all? Also does https://github.com/ansible/galaxy-dev/ or https://github.com/ansible/galaxy-importer/ use it? If not then I agree completely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I don't see it when I do a code search.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the log above is a stderr for ansible-galaxy, all the 3 tests that used it failed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failing tests are because this only adds the file extension on uploaded collection versions here. It also needs to be added to synced collection versions or else they will also be missing their file extensions too. Once I did that, I was able to set the file extension on the relative_path property and all the tests are passing now: #295.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I close this PR in favor of #295 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we still need the migration. I was hoping you could work on that and I could just close out #295 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I can do that

@@ -0,0 +1 @@
Including file type extension when uploading collections
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this also indicate that it fixes the user's busted database with a data migration.

Copy link
Member

@bmbouter bmbouter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. @daviddavis wdyt?

@fao89 fao89 merged commit 2118975 into pulp:master Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants