misc thumbservice todos

dave 2 years ago
parent a8725aa6af
commit 46d67365ba

@ -73,8 +73,9 @@ more information.
Optional: Photolib uses a secondary service to generate thumbnails for video files. After the above installation
instructions are complete, run `photothumbd` on a differnet port with the same arguments. On first run, it will create
a user for internal communications and log the username/password. This username/password must be used in the
`--thumb-service` for `photoappd`.
a user for internal communications and log the username/password or you can set `THUMBSERVICE_INITIAL_PASSWORD_HASH` to
the sha256 hash of the desired password. This username/password must be used in the `--thumb-service` option
for `photoappd`.

@ -20,7 +20,7 @@ from photoapp.common import pwhash
from photoapp.dbsession import DatabaseSession
from photoapp.thumb import thumb_path, image_file_style
from photoapp.webutils import validate_password
from photoapp.utils import genpw
from photoapp.utils import genpw, get_extension
@ -112,10 +112,13 @@ def setup_thumb_user(engine):
if u:
password = genpw()
password_hash = os.environ.get("THUMBSERVICE_INITIAL_PASSWORD_HASH")
if not password_hash:
password = genpw()
logging.warning("created thumbserver user: %s:%s", THUMBSERVICE_USER_INTERNAL, password)
password_hash = pwhash(password)
logging.warning("created thumbserver user: %s:%s", THUMBSERVICE_USER_INTERNAL, password)
s.add(User(name=THUMBSERVICE_USER_INTERNAL, password=pwhash(password)))
s.add(User(name=THUMBSERVICE_USER_INTERNAL, password=password_hash))
@ -188,8 +191,9 @@ class ThumbWorker(Thread):
# download the image
local_src_path = os.path.join(tmpdir, image.fname) # TODO fname isn't sanitized? use temp.<extension>
local_src_path = os.path.join(tmpdir, "input.{}".format(get_extension(image.fname)))
thumb_tmp_path = os.path.join(tmpdir, "thumb.jpg")
# TODO simplify low level operations like this
with (
self.library.open(image.path, "rb") as src,
open(local_src_path, "wb") as dest,
@ -265,7 +269,7 @@ def main():
parser = argparse.ArgumentParser(description="Photod photo server")
parser.add_argument('-p', '--port', help="tcp port to listen on",
default=int(os.environ.get("THUMB_SERVICE_PORT", 8081)), type=int)
default=int(os.environ.get("THUMBSERVICE_PORT", 8081)), type=int)
parser.add_argument('-l', '--library', default=os.environ.get("STORAGE_URL"), help="library path")
parser.add_argument('-c', '--cache', default=os.environ.get("CACHE_URL"), help="cache url")
# https://docs.sqlalchemy.org/en/13/core/engines.html