Updates a list of flows. If flow is not in the state, it's ignored.
(self, flows: Sequence[mitmproxy.flow.Flow])
| 632 | self.update([f]) |
| 633 | |
| 634 | def update(self, flows: Sequence[mitmproxy.flow.Flow]) -> None: |
| 635 | """ |
| 636 | Updates a list of flows. If flow is not in the state, it's ignored. |
| 637 | """ |
| 638 | for f in flows: |
| 639 | if f.id in self._store: |
| 640 | if self.filter(f): |
| 641 | if f not in self._view: |
| 642 | self._base_add(f) |
| 643 | if self.focus_follow: |
| 644 | self.focus.flow = f |
| 645 | self.sig_view_add.send(flow=f) |
| 646 | else: |
| 647 | # This is a tad complicated. The sortedcontainers |
| 648 | # implementation assumes that the order key is stable. If |
| 649 | # it changes mid-way Very Bad Things happen. We detect when |
| 650 | # this happens, and re-fresh the item. |
| 651 | self.order_key.refresh(f) |
| 652 | self.sig_view_update.send(flow=f) |
| 653 | else: |
| 654 | try: |
| 655 | idx = self._view.index(f) |
| 656 | except ValueError: |
| 657 | pass # The value was not in the view |
| 658 | else: |
| 659 | self._view.remove(f) |
| 660 | self.sig_view_remove.send(flow=f, index=idx) |
| 661 | |
| 662 | |
| 663 | class Focus: |