File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -114,18 +114,23 @@ def refresh_single_thread(thread):
114114 )
115115 if thread .latestmsgid != r [- 1 ]["msgid" ]:
116116 # There is now a newer mail in the thread!
117- thread .latestmsgid = r [- 1 ]["msgid" ]
118- thread .latestmessage = r [- 1 ]["date" ]
119- thread .latestauthor = r [- 1 ]["from" ]
120- thread .latestsubject = r [- 1 ]["subj" ]
121- thread .save ()
122117 parse_and_add_attachments (r , thread )
123118 # Potentially update the last mail date - if there wasn't already a mail on each patch
124119 # from a *different* thread that had an earlier date.
125120 for p in thread .patches .filter (lastmail__lt = thread .latestmessage ):
126121 p .lastmail = thread .latestmessage
127122 p .save ()
128123
124+ # Finally, we update the thread entry itself. We should only do that at
125+ # the end, in case any of the previous steps fail. Then we'll retry on
126+ # the next run. We could also do this in a transaction, but that would
127+ # mean we lock a bunch of rows for potentially a long time.
128+ thread .latestmsgid = r [- 1 ]["msgid" ]
129+ thread .latestmessage = r [- 1 ]["date" ]
130+ thread .latestauthor = r [- 1 ]["from" ]
131+ thread .latestsubject = r [- 1 ]["subj" ]
132+ thread .save ()
133+
129134
130135@transaction .atomic
131136def annotateMessage (request ):
You can’t perform that action at this time.
0 commit comments