Fix bug in news scheduling that caused news to download only after 24 hours had elapsed irrespective of the specified time

This commit is contained in:
Kovid Goyal 2009-01-29 10:23:34 -08:00
parent c362da37e2
commit 43fb366ef1

View File

@ -8,7 +8,7 @@ Scheduler for automated recipe downloads
''' '''
import sys, copy, time import sys, copy, time
from datetime import datetime, timedelta from datetime import datetime, timedelta, date
from PyQt4.Qt import QDialog, QApplication, QLineEdit, QPalette, SIGNAL, QBrush, \ from PyQt4.Qt import QDialog, QApplication, QLineEdit, QPalette, SIGNAL, QBrush, \
QColor, QAbstractListModel, Qt, QVariant, QFont, QIcon, \ QColor, QAbstractListModel, Qt, QVariant, QFont, QIcon, \
QFile, QObject, QTimer, QMutex, QMenu, QAction, QTime QFile, QObject, QTimer, QMutex, QMenu, QAction, QTime
@ -289,7 +289,8 @@ class SchedulerDialog(QDialog, Ui_Dialog):
recipe.last_downloaded = datetime.fromordinal(1) recipe.last_downloaded = datetime.fromordinal(1)
recipes.append(recipe) recipes.append(recipe)
if recipe.needs_subscription and not config['recipe_account_info_%s'%recipe.id]: if recipe.needs_subscription and not config['recipe_account_info_%s'%recipe.id]:
error_dialog(self, _('Must set account information'), _('This recipe requires a username and password')).exec_() error_dialog(self, _('Must set account information'),
_('This recipe requires a username and password')).exec_()
self.schedule.setCheckState(Qt.Unchecked) self.schedule.setCheckState(Qt.Unchecked)
return return
if self.interval_button.isChecked(): if self.interval_button.isChecked():
@ -433,7 +434,7 @@ class Scheduler(QObject):
day_matches = day > 6 or day == now.tm_wday day_matches = day > 6 or day == now.tm_wday
tnow = now.tm_hour*60 + now.tm_min tnow = now.tm_hour*60 + now.tm_min
matches = day_matches and (hour*60+minute) < tnow matches = day_matches and (hour*60+minute) < tnow
if matches and delta >= timedelta(days=1): if matches and nowt.toordinal() < date.today().toordinal():
needs_downloading.add(recipe) needs_downloading.add(recipe)
self.debug('Needs downloading:', needs_downloading) self.debug('Needs downloading:', needs_downloading)