Draft fix to mtime detection for files

This commit is contained in:
Worros 2008-10-17 01:36:02 +08:00
parent 10b0cc7bca
commit 5a085a6d23
2 changed files with 13 additions and 7 deletions

View File

@ -109,7 +109,7 @@ class GuiAutoImport (threading.Thread):
self.importer.setQuiet(False) self.importer.setQuiet(False)
self.importer.setFailOnError(False) self.importer.setFailOnError(False)
self.importer.setHandCount(0) self.importer.setHandCount(0)
self.importer.setWatchTime() # self.importer.setWatchTime()
self.server=settings['db-host'] self.server=settings['db-host']
self.user=settings['db-user'] self.user=settings['db-user']

View File

@ -50,7 +50,7 @@ class Importer:
self.filelist = [] self.filelist = []
self.dirlist = [] self.dirlist = []
self.monitor = False self.monitor = False
self.updated = 0 #Time last import was run, used as mtime reference self.updated = {} #Time last import was run {file:mtime}
self.callHud = False self.callHud = False
self.lines = None self.lines = None
self.faobs = None #File as one big string self.faobs = None #File as one big string
@ -96,8 +96,8 @@ class Importer:
def setFailOnError(self, value): def setFailOnError(self, value):
self.settings['failOnError'] = value self.settings['failOnError'] = value
def setWatchTime(self): # def setWatchTime(self):
self.updated = time() # self.updated = time()
def clearFileList(self): def clearFileList(self):
self.filelist = [] self.filelist = []
@ -142,9 +142,15 @@ class Importer:
for file in self.filelist: for file in self.filelist:
stat_info = os.stat(file) stat_info = os.stat(file)
if stat_info.st_mtime > self.updated: try:
lastupdate = self.updated[file]
# print "Is " + str(stat_info.st_mtime) + " > " + str(lastupdate)
if stat_info.st_mtime > lastupdate:
self.import_file_dict(file) self.import_file_dict(file)
self.updated = time() self.updated[file] = time()
except:
# print "Adding " + str(file) + " at approx " + str(time())
self.updated[file] = time()
# This is now an internal function that should not be called directly. # This is now an internal function that should not be called directly.
def import_file_dict(self, file): def import_file_dict(self, file):