From e32acae57297dd457f5bac9fe27e535135e7b619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Fri, 27 Jun 2025 23:58:21 +0200 Subject: [PATCH] upload fix --- Fotobox.py | 20 +++++++++----------- rsync.sh | 6 ++++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Fotobox.py b/Fotobox.py index 0645ddc..3641bde 100644 --- a/Fotobox.py +++ b/Fotobox.py @@ -237,10 +237,10 @@ class Fotobox: self._qr = qr_create(self._choice.urlWithProtocol) self._qr_rect = self._qr.get_rect(left=2 * BORDER, centery=SCREEN_RECT.centery) - self.save(self._choice.photo_image, "") - self.save(self._choice.framed_image, "framed") + self.save(self._choice.photo_image, "", False) + self.save(self._choice.framed_image, "framed", True) - def save(self, img: Image, suffix: str): + def save(self, img: Image, suffix: str, do_upload: bool): filename = "F-%s---R%04d-%s---S%04d-%s---P%04d-%s---%s%s.jpg" % ( self._fotobox_uuid, self._runtime_number, @@ -260,13 +260,11 @@ class Fotobox: )) path.parent.mkdir(parents=True, exist_ok=True) img.convert('RGB').save(path, format='JPEG', quality=95) - upload = Path("./data/photos/upload/%s" % (filename,)) - upload.parent.mkdir(parents=True, exist_ok=True) - os.link(path, upload) + if do_upload: + upload = Path("./data/photos/upload/%s.jpg" % (self._choice.code,)) + upload.parent.mkdir(parents=True, exist_ok=True) + os.chmod(upload.parent, 0o777) + os.link(path, upload) + os.chmod(upload, 0o777) print("Photo saved: %s" % path.absolute()) - - - - - diff --git a/rsync.sh b/rsync.sh index 9a8a248..fc3d56f 100755 --- a/rsync.sh +++ b/rsync.sh @@ -3,6 +3,8 @@ cd "$(dirname "$0")/data/photos/upload" || exit 1 while true; do - rsync -a -e 'ssh -p 2222' ./* mc@mc.ph87.de:/srv/fotobox.online/html/p/ - sleep 60 + if compgen -G "./*" > /dev/null; then + rsync -a --remove-source-files -e 'ssh -p 2222' ./* mc@mc.ph87.de:/srv/fotobox.online/html/p/ + fi + sleep 3 done