|
|
|
@ -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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
THUMBSERVICE_USER_INTERNAL = "_thumbservice"
|
|
|
|
@ -112,10 +112,13 @@ def setup_thumb_user(engine):
|
|
|
|
|
if u:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
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))
|
|
|
|
|
s.commit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -188,8 +191,9 @@ class ThumbWorker(Thread):
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|