Fix for RFE #818993, smarter PeriodicFileDownloader.

This commit is contained in:
Jeremy Fincher 2003-10-08 13:20:16 +00:00
parent f28bed51ec
commit 2fb9273518

View File

@ -85,12 +85,17 @@ class ChannelDBHandler(object):
def die(self): def die(self):
for db in self.dbCache.itervalues(): for db in self.dbCache.itervalues():
db.commit() try:
db.close() db.commit()
except AttributeError: # In case it's not an SQLite database.
pass
try:
db.close()
except AttributeError: # In case it doesn't have a close method.
pass
del db del db
class PeriodicFileDownloader(object): class PeriodicFileDownloader(object):
"""A class to periodically download a file/files. """A class to periodically download a file/files.
@ -127,7 +132,11 @@ class PeriodicFileDownloader(object):
self.lastDownloaded = {} self.lastDownloaded = {}
self.downloadedCounter = {} self.downloadedCounter = {}
for filename in self.periodicFiles: for filename in self.periodicFiles:
self.lastDownloaded[filename] = 0 if self.periodicFiles[filename][-1] is None:
fullPathname = os.path.join(conf.dataDir, filename)
self.lastDownloaded[filename] = os.stat(fullPathname).st_ctime
else:
self.lastDownloaded[filename] = 0
self.currentlyDownloading = sets.Set() self.currentlyDownloading = sets.Set()
self.downloadedCounter[filename] = 0 self.downloadedCounter[filename] = 0
self.getFile(filename) self.getFile(filename)