Merge lp:~humitos/encuentro/keep-trying-after-fail into lp:encuentro

Proposed by Facundo Batista
Status: Needs review
Proposed branch: lp:~humitos/encuentro/keep-trying-after-fail
Merge into: lp:encuentro
Diff against target: 71 lines (+18/-13)
1 file modified
encuentro/ui/central_panel.py (+18/-13)
To merge this branch: bzr merge lp:~humitos/encuentro/keep-trying-after-fail
Reviewer Review Type Date Requested Status
Facundo Batista Needs Fixing
Review via email: mp+217375@code.launchpad.net

Description of the change

Keep trying to download failed episodes

To post a comment you must log in.
Revision history for this message
Facundo Batista (facundo) wrote :

I don't like the "start from the first not downloaded after finishing the list" behaviour.

Yes, it's a good idea to retry those that failed. But what if it fails because of a non-spurious error (e.g., because the URL is wrong, or the video was removed in the backend, etc)?

In that case, the program will be in an endless loop, not only consuming local resources, but also hammering the backend services over and over again, getting the same error.

On the other hand, I like a lot the idea of marking specially the episode so it's kept after closing/opening the program. But it must not be 'waiting'... maybe something like 'failed', because of the program buttons (with 'waiting' it will not turn on the 'download' button, for example).

Maybe you could re-purpose this branch? Thanks!

review: Needs Fixing

Unmerged revisions

208. By Manuel Kaufmann

Keep trying to download failed episodes

When a download fails, Encuentro marks that episode as "State.waiting"
to try again later (once Encuentro reaches the end of the list).

All of the episodes that failed in the download process are saved to
disk when Encuentro is closed and load again when Encuentro is opened.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'encuentro/ui/central_panel.py'
--- encuentro/ui/central_panel.py 2014-04-26 02:36:13 +0000
+++ encuentro/ui/central_panel.py 2014-04-28 01:26:07 +0000
@@ -1,4 +1,4 @@
1# -*- coding: UTF-8 -*-1# -*- coding: utf-8 -*-
22
3# Copyright 2013-2014 Facundo Batista3# Copyright 2013-2014 Facundo Batista
4#4#
@@ -92,7 +92,12 @@
92 """Set up everything for next download."""92 """Set up everything for next download."""
93 self.downloading = True93 self.downloading = True
94 self.current += 194 self.current += 1
95 episode, _ = self.queue[self.current]95 try:
96 episode, _ = self.queue[self.current]
97 except IndexError:
98 # get the first pending episode
99 episode, _ = self.pending()[0]
100 self.current = self.queue.index((episode, _))
96 episode.state = Status.downloading101 episode.state = Status.downloading
97 return episode102 return episode
98103
@@ -100,6 +105,7 @@
100 """Download started."""105 """Download started."""
101 episode, item = self.queue[self.current]106 episode, item = self.queue[self.current]
102 item.setText(1, u"Comenzando")107 item.setText(1, u"Comenzando")
108 item.setDisabled(False)
103 episode.state = Status.downloading109 episode.state = Status.downloading
104110
105 def progress(self, progress):111 def progress(self, progress):
@@ -117,7 +123,8 @@
117 else:123 else:
118 # something bad happened124 # something bad happened
119 gui_msg = unicode(error)125 gui_msg = unicode(error)
120 end_state = Status.none126 # mark as waiting to try again later
127 end_state = Status.waiting
121 item.setText(1, gui_msg)128 item.setText(1, gui_msg)
122 item.setDisabled(True)129 item.setDisabled(True)
123 episode.state = end_state130 episode.state = end_state
@@ -150,21 +157,19 @@
150 self.episodes_widget.show(item.episode_id)157 self.episodes_widget.show(item.episode_id)
151158
152 def pending(self):159 def pending(self):
153 """Return the pending downloads quantity (including current)."""160 pending_episodes = []
154 # remaining after current one161 for episode, item in self.queue:
155 q = len(self.queue) - self.current - 1162 if episode.state in (Status.waiting, Status.none):
156 # if we're still downloading current one, add it to the count163 pending_episodes.append((episode, item))
157 if self.downloading:164 return pending_episodes
158 q += 1
159 return q
160165
161 def save_state(self):166 def save_state(self):
162 """Save state for pending downloads."""167 """Save state for pending downloads."""
163 p = self.pending()168 if self.pending():
164 if p > 0:169 pending_ids = [e.episode_id for e, _ in self.pending()]
165 pending_ids = [e.episode_id for e, _ in self.queue[-p:]]
166 else:170 else:
167 pending_ids = []171 pending_ids = []
172
168 config[config.SYSTEM]['pending_ids'] = pending_ids173 config[config.SYSTEM]['pending_ids'] = pending_ids
169174
170 def load_pending(self):175 def load_pending(self):

Subscribers

People subscribed via source and target branches