Refactoring and cleanup
This commit is contained in:
parent
e90174a09d
commit
e68a05e663
|
@ -1,13 +1,13 @@
|
|||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from docopt import docopt
|
||||
|
||||
from . import app, config, droppy, httpredir, pwgen, serve
|
||||
from ._version import version
|
||||
from cista import app, config, droppy, serve, server80
|
||||
from cista._version import version
|
||||
from cista.util import pwgen
|
||||
|
||||
app, httpredir.app # Needed for Sanic multiprocessing
|
||||
app, server80.app # Needed for Sanic multiprocessing
|
||||
|
||||
doc = f"""Cista {version} - A file storage for the web.
|
||||
|
||||
|
|
|
@ -7,11 +7,10 @@ from sanic import Forbidden, Sanic, SanicException, errorpages
|
|||
from sanic.log import logger
|
||||
from sanic.response import html, json, redirect
|
||||
|
||||
from . import config, session, watching
|
||||
from .auth import authbp
|
||||
from .fileio import FileServer
|
||||
from .protocol import ControlBase, ErrorMsg, FileRange, StatusMsg
|
||||
|
||||
from cista import config, session, watching
|
||||
from cista.auth import authbp
|
||||
from cista.fileio import FileServer
|
||||
from cista.protocol import ControlBase, ErrorMsg, FileRange, StatusMsg
|
||||
|
||||
app = Sanic("cista")
|
||||
fileserver = FileServer()
|
||||
|
|
|
@ -8,7 +8,7 @@ import msgspec
|
|||
from html5tagger import Document
|
||||
from sanic import BadRequest, Blueprint, Forbidden, html, json, redirect
|
||||
|
||||
from . import config, session
|
||||
from cista import config, session
|
||||
|
||||
_argon = argon2.PasswordHasher()
|
||||
_droppyhash = re.compile(r'^([a-f0-9]{64})\$([a-f0-9]{8})$')
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import asyncio
|
||||
import os
|
||||
import unicodedata
|
||||
from pathlib import Path, PurePosixPath
|
||||
from pathlib import PurePosixPath
|
||||
|
||||
from pathvalidate import sanitize_filepath
|
||||
|
||||
from . import config, protocol
|
||||
from .asynclink import AsyncLink
|
||||
from .lrucache import LRUCache
|
||||
from cista import config
|
||||
from cista.util.asynclink import AsyncLink
|
||||
from cista.util.lrucache import LRUCache
|
||||
|
||||
|
||||
def fuid(stat) -> str:
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import shutil
|
||||
|
||||
import msgspec
|
||||
from sanic import BadRequest
|
||||
|
||||
from cista import config
|
||||
from cista.fileio import sanitize_filename
|
||||
|
||||
import msgspec
|
||||
|
||||
## Control commands
|
||||
|
||||
class ControlBase(msgspec.Struct, tag_field="op", tag=str.lower):
|
||||
|
|
|
@ -4,7 +4,7 @@ from pathlib import Path
|
|||
|
||||
from sanic import Sanic
|
||||
|
||||
from . import config
|
||||
from cista import config
|
||||
|
||||
|
||||
def run(dev=False):
|
||||
|
@ -15,8 +15,8 @@ def run(dev=False):
|
|||
os.environ["SANIC_IGNORE_PRODUCTION_WARNING"] = "1"
|
||||
if opts.get("ssl"):
|
||||
# Run plain HTTP redirect/acme server on port 80
|
||||
from . import httpredir
|
||||
httpredir.app.prepare(port=80, motd=False)
|
||||
from . import server80
|
||||
server80.app.prepare(port=80, motd=False)
|
||||
domain = opts["host"]
|
||||
opts["ssl"] = str(config.conffile.parent / domain)
|
||||
app.prepare(**opts, motd=False, dev=dev, auto_reload=dev, access_log=True)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from sanic import Sanic, exceptions, response
|
||||
|
||||
app = Sanic("http_redirect")
|
||||
app = Sanic("server80")
|
||||
|
||||
# Send all HTTP users to HTTPS
|
||||
@app.exception(exceptions.NotFound, exceptions.MethodNotSupported)
|
|
@ -2,7 +2,7 @@ from time import time
|
|||
|
||||
import jwt
|
||||
|
||||
from .config import derived_secret
|
||||
from cista.config import derived_secret
|
||||
|
||||
session_secret = lambda: derived_secret("session")
|
||||
max_age = 60 # Seconds since last login
|
||||
|
|
|
@ -2,13 +2,12 @@ import asyncio
|
|||
import threading
|
||||
import time
|
||||
from pathlib import Path, PurePosixPath
|
||||
from socket import timeout
|
||||
|
||||
import inotify.adapters
|
||||
import msgspec
|
||||
|
||||
from . import config
|
||||
from .protocol import DirEntry, FileEntry, UpdateEntry
|
||||
from cista import config
|
||||
from cista.protocol import DirEntry, FileEntry, UpdateEntry
|
||||
|
||||
pubsub = {}
|
||||
tree = {"": None}
|
||||
|
|
|
@ -3,7 +3,7 @@ from unittest.mock import Mock
|
|||
|
||||
import pytest
|
||||
|
||||
from cista.lrucache import LRUCache # Replace with actual import
|
||||
from cista.util.lrucache import LRUCache # Replace with actual import
|
||||
|
||||
|
||||
def mock_open(key):
|
||||
|
|
Loading…
Reference in New Issue
Block a user