Allow to pass file object on file updated

This commit is contained in:
ZeroNet 2016-08-10 12:31:30 +02:00
parent 3ff75c6602
commit acf24aab6f

View file

@ -203,19 +203,20 @@ class SiteStorage(object):
yield file_name yield file_name
# Site content updated # Site content updated
def onUpdated(self, inner_path): def onUpdated(self, inner_path, file=None):
file_path = self.getPath(inner_path) file_path = self.getPath(inner_path)
# Update Sql cache # Update Sql cache
if inner_path == "dbschema.json": if inner_path == "dbschema.json":
self.has_db = self.isFile("dbschema.json") self.has_db = self.isFile("dbschema.json")
# Reopen DB to check changes # Reopen DB to check changes
if self.has_db:
self.closeDb() self.closeDb()
self.openDb() self.openDb()
elif not config.disable_db and inner_path.endswith(".json") and self.has_db: # Load json file to db elif not config.disable_db and inner_path.endswith(".json") and self.has_db: # Load json file to db
if config.verbose: if config.verbose:
self.log.debug("Loading json file to db: %s" % inner_path) self.log.debug("Loading json file to db: %s" % inner_path)
try: try:
self.getDb().loadJson(file_path) self.getDb().loadJson(file_path, file)
except Exception, err: except Exception, err:
self.log.error("Json %s load error: %s" % (inner_path, Debug.formatException(err))) self.log.error("Json %s load error: %s" % (inner_path, Debug.formatException(err)))
self.closeDb() self.closeDb()