-
Notifications
You must be signed in to change notification settings - Fork 700
Description
Description
find_disconnected_fs_submissions() checks for submission and reply files missing from the database, since their filenames exist in the same space:
securedrop/securedrop/management/submissions.py
Lines 85 to 89 in f5ca29b
| 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
- Register as a source and submit something.
- Reply.
- Delete that source's directory from
/var/lib/securedrop/store. 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:
securedrop/securedrop/models.py
Line 116 in f5ca29b
| 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().