Skip to content

Attachments task UIDs are properly tracked and handled. #36

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions python/version_details/version_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self, bg_task_manager, parent=None, entity=None):
self._version_context_menu_actions = []
self._note_metadata_uids = []
self._note_set_metadata_uids = []
self._uploads_uids = []
self._upload_uids = {}
self._attachment_uids = {}
self._note_fields = [self.NOTE_METADATA_FIELD]
self._attachments_filter = None
Expand Down Expand Up @@ -366,15 +366,16 @@ def add_note_attachments(self, file_paths, note_entity, cleanup_after_upload=Tru
note_entity = note_entity["entity"]

for file_path in file_paths:
self._upload_uids.append(self._data_retriever.execute_method(
upload_uid = self._data_retriever.execute_method(
self.__upload_file,
dict(
file_path=file_path,
parent_entity_type=note_entity["type"],
parent_entity_id=note_entity["id"],
cleanup_after_upload=cleanup_after_upload,
),
))
)
self._upload_uids[upload_uid] = note_entity

def add_query_fields(self, fields):
"""
Expand Down Expand Up @@ -680,6 +681,12 @@ def __on_worker_signal(self, uid, request_type, data):
self.note_attachment_arrived.emit(note_id, data["file_path"])
elif uid in self._upload_uids:
self.ui.note_stream_widget.rescan(force_activity_stream_update=True)
# TODO: It's not great that we're turning around and re-downloading this
# data again, but it's BY FAR the easiest way to make this work right now.
# It would probably be best to revisit this if, at some time in the future,
# the activity_stream widget is refactored to make it a little friendlier
# to data changing after it's already cached.
self.download_note_attachments(note_id=self._upload_uids[uid]["id"])

def __on_worker_failure(self, uid, msg):
"""
Expand Down