def __add_ctype_to_index(self, ctype):
"""Take a file type, list all the files there, and add all the
body contents to the index."""
# Make sure BaseFiles is populated
opendir(self.config, ctype)
card_root = GlobalConfig.get("paths", "data_root") + "/private"
card_path = card_root + "/" + self.config.get("paths", ctype)
for filename in BaseFiles[ctype]:
try:
fnmtime = int(os.path.getmtime(card_path + "/" + filename))
except os.error:
syslog.syslog("Failed to get \"" + filename + "\" mtime for indexing.")
return # File has been removed, nothing to index
lastmtime = ''
try:
lastmtime = int(float(self.searcher.document(file=unicode(filename))['mtime']))
except index.IndexError:
lastmtime = 0 # File hasn't been indexed
# If small revisions were made after the fact, the indexes won't
# be accurate unless we reindex this file now
if lastmtime < fnmtime:
self.__add_file_to_index(fnmtime, filename, ctype)
评论列表
文章目录