Handle the returning None
@@ -838,6 +838,8 @@ def sync_files(project_pk, version_pk, hostname=None, html=False,
"""
# Clean up unused artifacts
version = Version.objects.get_object_or_log(pk=version_pk)
+ if not version:
+ return
if not pdf:
remove_dir(
version.project.get_production_media_path(
@@ -891,6 +893,8 @@ def move_files(version_pk, hostname, html=False, localmedia=False,
:type epub: bool
"""
version = Version.objects.get_object_or_log(pk=version_pk)
+ if not version:
+ return
log.debug(
LOG_TEMPLATE.format(
project=version.project.slug,
@@ -967,6 +971,8 @@ def update_search(version_pk, commit, delete_non_commit_files=True):
:param delete_non_commit_files: Delete files not in commit from index
"""
version = Version.objects.get_object_or_log(pk=version_pk)
+ if not version:
+ return
if 'sphinx' in version.project.documentation_type:
page_list = process_all_json_files(version, build_dir=False)
@@ -1057,6 +1063,8 @@ def fileify(version_pk, commit):
This is so we have an idea of what files we have in the database.
"""
version = Version.objects.get_object_or_log(pk=version_pk)
+ if not version:
+ return
project = version.project
if not commit:
@@ -1139,6 +1147,8 @@ def _manage_imported_files(version, path, commit):
@app.task(queue='web')
def send_notifications(version_pk, build_pk):
version = Version.objects.get_object_or_log(pk=version_pk)
+ if not version:
+ return
build = Build.objects.get(pk=build_pk)
for hook in version.project.webhook_notifications.all():
