Skip to content

Commit

Permalink
Feature/check file exists before ingesting it (#1361)
Browse files Browse the repository at this point in the history
* feature/chec-file-exists-before-ingesting-it

* fixed task getattr
  • Loading branch information
gecBurton authored Feb 4, 2025
1 parent acc3ea0 commit e91e194
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion django_app/redbox_app/redbox_core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ def get_ordered_by_citation_priority(cls, chat_message_id: uuid.UUID) -> Sequenc
)

def position_in_queue(self) -> int:
if not self.task:
if not self.task_id:
return -1
return OrmQ.objects.filter(lock__lt=self.task.lock).count()

Expand Down
6 changes: 5 additions & 1 deletion django_app/redbox_app/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ def ingest(file_id: UUID) -> None:
# These models need to be loaded at runtime otherwise they can be loaded before they exist
from redbox_app.redbox_core.models import File

file = File.objects.get(id=file_id)
try:
file = File.objects.get(id=file_id)
except File.DoesNotExist:
logging.info("file_id=%s no longer exists, has the user deleted it?", file_id)
return

logging.info("Ingesting file: %s", file)

Expand Down

0 comments on commit e91e194

Please sign in to comment.