From 5a085a6d236197ff9f066423b1cd95f8d9a71d85 Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 17 Oct 2008 01:36:02 +0800 Subject: [PATCH] Draft fix to mtime detection for files --- pyfpdb/GuiAutoImport.py | 2 +- pyfpdb/fpdb_import.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py index 6953d1f9..e4d145dd 100644 --- a/pyfpdb/GuiAutoImport.py +++ b/pyfpdb/GuiAutoImport.py @@ -109,7 +109,7 @@ class GuiAutoImport (threading.Thread): self.importer.setQuiet(False) self.importer.setFailOnError(False) self.importer.setHandCount(0) - self.importer.setWatchTime() +# self.importer.setWatchTime() self.server=settings['db-host'] self.user=settings['db-user'] diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 12e854c0..860cb778 100755 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -50,7 +50,7 @@ class Importer: self.filelist = [] self.dirlist = [] 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.lines = None self.faobs = None #File as one big string @@ -96,8 +96,8 @@ class Importer: def setFailOnError(self, value): self.settings['failOnError'] = value - def setWatchTime(self): - self.updated = time() +# def setWatchTime(self): +# self.updated = time() def clearFileList(self): self.filelist = [] @@ -142,9 +142,15 @@ class Importer: for file in self.filelist: stat_info = os.stat(file) - if stat_info.st_mtime > self.updated: - self.import_file_dict(file) - self.updated = time() + 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.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. def import_file_dict(self, file):