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

Use PATHs to call clear_artifacts #4296

Merged
merged 1 commit into from
Jun 25, 2018
Merged

Conversation

humitos
Copy link
Member

@humitos humitos commented Jun 25, 2018

Use a list of PATHs Instead of using a Version.pk when calling clear_artifacts. This is because in the Version.delete method, the Version object is removed immediately after broadcasting the clear_artifacts task and that could produce a race condition.

With this change, we calculate all the PATHs needed before broadcasting the task and before deleting the object from the database.

Use a list of PATHs Instead of using a ``Version.pk`` when calling
`clear_artifacts`. This is because in the ``Version.delete`` method,
the Version object is removed immediately after broadcasting the
``clear_artifacts`` task and that could produce a race condition.

With this change, we calculate all the PATHs needed _before_
broadcasting the task and _before_ deleting the object from the
database.
@humitos humitos requested a review from agjohnson June 25, 2018 14:57
remove_dir(version.project.get_production_media_path(
type_='htmlzip', version_slug=version.slug))

def clear_artifacts(paths):
Copy link
Member Author

Choose a reason for hiding this comment

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

I kept the name, but it could be changed to remove_dirs. Although, it won't reflect the specific usage that we give to this task.

@humitos humitos requested a review from a team June 25, 2018 15:11
Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

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

Looks good! An incremental change here is okay. I think remove_dir and clear_artifacts could be merged into a single task next though.

We'll want to make sure this PR doesn't incur a change on the commercial side.

@humitos
Copy link
Member Author

humitos commented Jun 25, 2018

We'll want to make sure this PR doesn't incur a change on the commercial side.

I grepped the code with clear_ and I didn't find anything that could be affected by this change. I think we are safe on that.

@humitos humitos merged commit 27722ff into master Jun 25, 2018
@humitos humitos deleted the humitos/clearartifacts/use-paths branch June 25, 2018 17:25
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.

2 participants