-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
app: delete source collection when source is deleted locally #866
Conversation
""" | ||
Delete the source with the referenced UUID. | ||
""" | ||
source = session.query(Source).filter_by(uuid=uuid).one_or_none() | ||
if source: | ||
delete_source_collection(source.journalist_filename, data_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checking my understanding: before we were only deleting the source locally from the db after we successfully sent a source-deletion job to the server, and then we'd rely on the metadata sync to tell us to delete a sources files on disk:
securedrop-client/securedrop_client/storage.py
Lines 205 to 215 in 707dde4
# The uuids remaining in local_uuids do not exist on the remote server, so | |
# delete the related records. | |
for deleted_source in local_sources_by_uuid.values(): | |
for document in deleted_source.collection: | |
if isinstance(document, (Message, File, Reply)): | |
delete_single_submission_or_reply_on_disk(document, data_dir) | |
session.delete(deleted_source) | |
logger.debug('Deleted source {}'.format(deleted_source.uuid)) | |
session.commit() |
this change makes it so we will delete a source's files ahead of time, before a sync? or was there a bug where the files were never getting deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Back when we were calling sync_api
after a deletion in the deletion success callback: the sync would delete the files from a deleted source. The deletion job itself would not delete either the database row or the corresponding files, relying on the sync to do so. After we removed the sync_api
call, it was replaced with a function in the deletion success callback that only deleted the database row. I don't think the intention was to rely on the sync in that case, since that would not have worked - the corresponding database rows (which the sync uses to determine which items to delete) are now gone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so i have a comment that is fine to respond to after merge
code lgtm and works
Description
Fixes #856
There are two ways sources can be deleted: via the metadata sync (since sources and submissions can be deleted by other users) and via the source deletion job (if the client user deletes a source). In the latter place, we were previously only deleting the source database row, the documents would remain on disk.
Test Plan
sd-app
, OR by copying the AppArmor profile into place (in/etc/apparmor.d/
), runningsudo service apparmor restart
, and copying the code on top of the existing installed code (e.g. in the root of the git repositorysudo cp -r securedrop_client /opt/venvs/securedrop-client/lib/python3.7/site-packages/
).securedrop-client
.ls -la ~/.securedrop_client/data
. You should see a folder in here with the designation of the source, and the file inside that folder.ls -la ~/.securedrop_client/data
. You should see the file and the entire folder is now gone.Checklist
If these changes modify code paths involving cryptography, the opening of files in VMs or network (via the RPC service) traffic, Qubes testing in the staging environment is required. For fine tuning of the graphical user interface, testing in any environment in Qubes is required. Please check as applicable:
If these changes add or remove files other than client code, packaging logic (e.g., the AppArmor profile) may need to be updated. Please check as applicable: