commit d71097373e04c47f1364e02153f263476a946104
parent c6e591f09fbf85254ef30e4a018fead35c379e0a
Author: René Wagner <rwa@clttr.info>
Date: Sun, 8 May 2022 11:03:00 +0200
some adjustments
Diffstat:
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/gus/build_index.py b/gus/build_index.py
@@ -7,6 +7,7 @@ from urllib.parse import uses_relative, uses_netloc
from . import constants
from gus.crawl import should_skip
from gus.excludes import EXCLUDED_URL_PREFIXES
+from . import constants
from gus.lib.db_model import init_db, Page
from gus.lib.gemini import GeminiResource
from gus.lib.index_statistics import (
@@ -82,7 +83,9 @@ AND l.is_cross_host_like == 1""",
def build_index(should_run_destructive=False):
index_dir = constants.INDEX_DIR_NEW if should_run_destructive else constants.INDEX_DIR
- db = init_db(index_dir + "/gus.sqlite")
+ db = init_db(f"{index_dir}/{constants.DB_FILENAME}", pragmas={
+ 'journal_mode': 'wal',
+ 'cache_size': -128 * 1000})
index = search.Index(index_dir, should_run_destructive)
if (should_run_destructive):
diff --git a/serve/models.py b/serve/models.py
@@ -17,7 +17,9 @@ TEXT_CONTENT_TYPE = ["text/plain", "text/gemini", "text/markdown"]
class GUS:
def __init__(self):
self.index = search.Index(constants.INDEX_DIR)
- self.db = init_db(f"{constants.INDEX_DIR}/{constants.DB_FILENAME}")
+ self.db = init_db(f"{constants.INDEX_DIR}/{constants.DB_FILENAME}", pragmas={
+ 'journal_mode': 'wal',
+ 'cache_size': -128 * 1000})
self.statistics = compute_index_statistics(self.db)
self.statistics_historical_overall = load_all_statistics_from_file(
constants.STATISTICS_FILE)
@@ -66,7 +68,7 @@ class GUS:
OR p.url LIKE '%.atom'
OR p.content_type IN ('application/atom+xml', 'application/rss+xml'))
""")
- self.feeds = feeds_query.execute()
+ self.feeds = feeds_query.execute()
def search_index(self, query, requested_page):
@@ -155,6 +157,8 @@ def compute_verbose(request_path):
def process_seed_request(seed_request):
with open(constants.SEED_REQUEST_FILE, "a") as seed_file:
- if not seed_request.startswith("gemini://"):
+ if seed_request.startswith("Gemini://"):
+ seed_request = seed_request.replace('G', 'g', 1)
+ if not seed_request.startswith("gemini://":
seed_request = "gemini://{}".format(seed_request)
seed_file.write("{}\n".format(seed_request))