Always checks time before append hit

This commit is contained in:
Grégory Soutadé 2014-12-12 13:18:12 +01:00
parent 15d2877e5a
commit 2c3d8d22f8

10
iwla.py
View File

@ -194,7 +194,7 @@ class IWLA(object):
return self.display
def getDBFilename(self, time):
return os.path.join(conf.DB_ROOT, str(time.tm_year), str(time.tm_mon), conf.DB_FILENAME)
return os.path.join(conf.DB_ROOT, str(time.tm_year), '%02d' % time.tm_mon, conf.DB_FILENAME)
def _serialize(self, obj, filename):
base = os.path.dirname(filename)
@ -514,7 +514,6 @@ class IWLA(object):
os.remove(path)
print "==> Serialize to %s" % path
self._serialize(self.current_analysis, path)
# Save month stats
@ -568,11 +567,10 @@ class IWLA(object):
self.current_analysis = self._deserialize(self.getDBFilename(t)) or self._clearVisits()
self.analyse_started = True
else:
if time.mktime(t) < time.mktime(cur_time):
return False
if not self.analyse_started:
if time.mktime(t) < time.mktime(cur_time):
return False
else:
self.analyse_started = True
self.analyse_started = True
if cur_time.tm_mon != t.tm_mon:
self._generateMonthStats()
self.current_analysis = self._deserialize(self.getDBFilename(t)) or self._clearVisits()