Skip to content

find_disconnected_db_submissions() does not check for disconnected replies #7203

@cfm

Description

@cfm

Description

find_disconnected_fs_submissions() checks for submission and reply files missing from the database, since their filenames exist in the same space:

submissions = Submission.query.order_by(Submission.id, Submission.filename).all()
files_in_db = {s.filename: True for s in submissions}
replies = Reply.query.order_by(Reply.id, Reply.filename).all()
files_in_db.update({r.filename: True for r in replies})

find_disconnected_db_submissions() does not check for submission and reply records missing from the filesystem, since their IDs do not exist in the same space:

submissions = db.session.query(Submission).order_by(Submission.id, Submission.filename).all()

As a result, manage.py delete-disconnected-db-submissions cannot remove a disconnected reply.

Steps to Reproduce

  1. Register as a source and submit something.
  2. Reply.
  3. Delete that source's directory from /var/lib/securedrop/store.
  4. manage.py delete-disconnected-db-submissions

Expected Behavior

The reply is deleted from the database.

Actual Behavior

The reply is not deleted from the database.

Comments

The fundamental issue here is the subtyping within:

collection: List[Union[Submission, Reply]] = []

For now we'd probably just want to add a separate find_disconnected_db_replies() function and iterate over that separately in delete_disconnected_db_replies().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions