Commit d3f1a1f3 authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

schedule tasks after replacing files

parent 839c40cd
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -2237,11 +2237,12 @@ def replace_file(user: User, from_resource_id: int, to_resource_id: int) -> bool
        from_resource_instance.delete()
        # save to_resource
        to_resource_instance.file.save()
        tasks.iiif_task(to_resource_instance.file.id)
        tasks.ocr_task(to_resource_instance.file.id)
        tasks.hls_task(to_resource_instance.file.id)
        # schedule so the tasks happen AFTER the current transaction
        tasks.iiif_task.schedule((to_resource_instance.file.id,), delay=2)
        tasks.ocr_task.schedule((to_resource_instance.file.id,), delay=2)
        tasks.hls_task.schedule((to_resource_instance.file.id,), delay=2)
        if to_resource_instance.ptr_project.use_exiftool:
            tasks.exif_task(to_resource_instance.file.id)
            tasks.exif_task.schedule((to_resource_instance.file.id,), delay=2)
        return True
    except Resource.DoesNotExist:
        raise ServiceException(NO_SUCH_RESOURCE)