Skip to content

Commit

Permalink
close freedomofpress#360 fix db warnings upon source deletion
Browse files Browse the repository at this point in the history
warnings were caused by double deletion of messages
  - once upon updating the sources
  - another upon updating files, messages and replies
  • Loading branch information
deeplow committed Oct 22, 2019
1 parent df66f46 commit 99fd7e6
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions securedrop_client/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,16 @@ def update_local_storage(session: Session,
with this data.
"""

local_sources = get_local_sources(session)
local_files = get_local_files(session)
local_messages = get_local_messages(session)
local_replies = get_local_replies(session)

remote_messages = [x for x in remote_submissions if x.filename.endswith('msg.gpg')]
remote_files = [x for x in remote_submissions if not x.filename.endswith('msg.gpg')]

update_sources(remote_sources, local_sources, session, data_dir)
update_files(remote_files, local_files, session, data_dir)
update_messages(remote_messages, local_messages, session, data_dir)
update_replies(remote_replies, local_replies, session, data_dir)
# The following update_* functions may change the database state.
# Because of that, each get_local_* function needs to be called just before
# its respective update_* function.
update_sources(remote_sources, get_local_sources(session), session, data_dir)
update_files(remote_files, get_local_files(session), session, data_dir)
update_messages(remote_messages, get_local_messages(session), session, data_dir)
update_replies(remote_replies, get_local_replies(session), session, data_dir)


def update_sources(remote_sources: List[SDKSource],
Expand Down

0 comments on commit 99fd7e6

Please sign in to comment.