Skip to content

Commit

Permalink
Force update of filename in conversation preview in source list when …
Browse files Browse the repository at this point in the history
…file is downloaded.
  • Loading branch information
ntoll authored and sssoleileraaa committed Jan 16, 2020
1 parent 5ae96f7 commit acfe31c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion securedrop_client/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def __str__(self) -> str:
Return something that's a useful string representation of the file.
"""
if self.is_downloaded:
return "File: {}".format(self.filename)
return "File: {}".format(self.original_filename)
else:
return '<Encrypted file on server>'

Expand Down
2 changes: 2 additions & 0 deletions securedrop_client/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ def on_message_download_success(self, uuid: str) -> None:
self.gui.clear_error_status() # remove any permanent error status message
message = storage.get_message(self.session, uuid)
self.message_ready.emit(message.uuid, message.content)
self.update_sources()

def on_message_download_failure(self, exception: Exception) -> None:
"""
Expand Down Expand Up @@ -732,6 +733,7 @@ def on_file_download_success(self, result: Any) -> None:
"""
self.gui.clear_error_status() # remove any permanent error status message
self.file_ready.emit(result)
self.update_sources()

def on_file_download_failure(self, exception: Exception) -> None:
"""
Expand Down
4 changes: 4 additions & 0 deletions tests/test_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ def test_Controller_on_file_downloaded_success(homedir, config, mocker, session_
mock_gui = mocker.MagicMock()

co = Controller('http://localhost', mock_gui, session_maker, homedir)
co.update_sources = mocker.MagicMock()

# signal when file is downloaded
mock_file_ready = mocker.patch.object(co, 'file_ready')
Expand All @@ -777,6 +778,7 @@ def test_Controller_on_file_downloaded_success(homedir, config, mocker, session_
co.on_file_download_success(mock_uuid)

mock_file_ready.emit.assert_called_once_with(mock_uuid)
co.update_sources.assert_called_once_with()


def test_Controller_on_file_downloaded_api_failure(homedir, config, mocker, session_maker):
Expand Down Expand Up @@ -1209,13 +1211,15 @@ def test_Controller_on_message_downloaded_success(mocker, homedir, session_maker
Check that a successful download emits proper signal.
"""
co = Controller('http://localhost', mocker.MagicMock(), session_maker, homedir)
co.update_sources = mocker.MagicMock()
message_ready = mocker.patch.object(co, 'message_ready')
message = factory.Message(source=factory.Source())
mocker.patch('securedrop_client.storage.get_message', return_value=message)

co.on_message_download_success(message.uuid)

message_ready.emit.assert_called_once_with(message.uuid, message.content)
co.update_sources.assert_called_once_with()


def test_Controller_on_message_downloaded_failure(mocker, homedir, session_maker):
Expand Down

0 comments on commit acfe31c

Please sign in to comment.