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

Conversation

Projects
None yet
2 participants
@humitos
Member

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 PATHs to call clear_artifacts
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 Jun 25, 2018

remove_dir(version.project.get_production_media_path(
type_='htmlzip', version_slug=version.slug))
def clear_artifacts(paths):

This comment has been minimized.

@humitos

humitos Jun 25, 2018

Member

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 rtfd/core Jun 25, 2018

@agjohnson

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

This comment has been minimized.

Member

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@humitos humitos deleted the humitos/clearartifacts/use-paths branch Jun 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment