Rev445, Fix ConnectionServer peer_id handling, Faster startup by creating ssl certs on FileServer start, Per-site connection_server, Fix double Db opening, Test site downloading, Sign testsite properly, Test ConnectionServer, Test FileRequest
This commit is contained in:
parent
891c5cc34a
commit
8fdc431b0b
26 changed files with 459 additions and 266 deletions
|
@ -4,7 +4,6 @@ import logging
|
|||
import hashlib
|
||||
import re
|
||||
import time
|
||||
import string
|
||||
import random
|
||||
import sys
|
||||
import binascii
|
||||
|
@ -50,7 +49,11 @@ class Site:
|
|||
self.storage = SiteStorage(self, allow_create=allow_create) # Save and load site files
|
||||
self.loadSettings() # Load settings from sites.json
|
||||
self.content_manager = ContentManager(self) # Load contents
|
||||
|
||||
self.connection_server = None
|
||||
if "main" in sys.modules and "file_server" in dir(sys.modules["main"]): # Use global file server by default if possible
|
||||
self.connection_server = sys.modules["main"].file_server
|
||||
else:
|
||||
self.connection_server = None
|
||||
if not self.settings.get("auth_key"): # To auth user in site (Obsolete, will be removed)
|
||||
self.settings["auth_key"] = CryptHash.random()
|
||||
self.log.debug("New auth key: %s" % self.settings["auth_key"])
|
||||
|
@ -430,6 +433,7 @@ class Site:
|
|||
|
||||
# Rebuild DB
|
||||
if new_site.storage.isFile("dbschema.json"):
|
||||
new_site.storage.closeDb()
|
||||
new_site.storage.rebuildDb()
|
||||
|
||||
return new_site
|
||||
|
|
|
@ -17,7 +17,6 @@ class SiteStorage:
|
|||
|
||||
def __init__(self, site, allow_create=True):
|
||||
self.site = site
|
||||
self.fs_encoding = sys.getfilesystemencoding()
|
||||
self.directory = "%s/%s" % (config.data_dir, self.site.address) # Site data diretory
|
||||
self.allowed_dir = os.path.abspath(self.directory) # Only serve/modify file within this dir
|
||||
self.log = site.log
|
||||
|
@ -39,7 +38,10 @@ class SiteStorage:
|
|||
if check:
|
||||
if not os.path.isfile(db_path) or os.path.getsize(db_path) == 0: # Not exist or null
|
||||
self.rebuildDb()
|
||||
self.db = Db(schema, db_path)
|
||||
|
||||
if not self.db:
|
||||
self.db = Db(schema, db_path)
|
||||
|
||||
if check and not self.db_checked:
|
||||
changed_tables = self.db.checkTables()
|
||||
if changed_tables:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue