karlomikus / bar-assistant

Bar assistant is a all-in-one solution for managing your home bar
https://barassistant.app
MIT License
592 stars 22 forks source link

Replacing Images Issue #343

Closed PoeticArcher closed 3 weeks ago

PoeticArcher commented 1 month ago

So, I've gotten pretty much everything working and it works well, thank you! But the problem is I cannot replace an image. When I replace an existing imported cocktail image it goes blank. It seems the image does not end up in the sqllite database either.

karlomikus commented 1 month ago

Hello,

Can you describe steps how to recreate it. I don't know what you mean by replace an image. Is normal image upload working?

PoeticArcher commented 1 month ago

No I can't upload an image, when I try to it appears in the editing screen but upon saving defaults back to default image. I have images from imported cocktails. I tried to replace those with another and it defaults and does not replace.

karlomikus commented 1 month ago

You'll have to check docker logs for errors, also console/network errors in the browser.

wildegnux commented 1 month ago

I have what appears to be the same issue on a fresh install. Trying to upload an image for an ingredient gives no errors in the front-end, but logs shows errors:

bar-assistant  | 2024/10/30 22:53:22 [warn] 200#200: *543 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000002, client: 172.16.22.5, server: _, request: "POST /api/images HTTP/1.1", host: "bar-api.***", referrer: "https://bar.***/"
bar-assistant  | [2024-10-30 22:53:23] production.ERROR: [IMAGE_SERVICE] libvips error: /var/www/cocktails/storage/bar-assistant/uploads/temp/PKZJpPpY7VTb1n6DPPzFFOQT4sfXBRU3wFr4A2va.webp: unable to open for write
bar-assistant  | unix error: No such file or directory

Inspecting the directory in the container gives away what the issue is:

$ docker compose exec bar-assistant ls -ahl /var/www/cocktails/storage/bar-assistant/uploads
total 20K
drwxr-xr-x 5 www-data www-data 4.0K Oct 30 23:03 .
drwxr-xr-x 4 www-data www-data 4.0K Oct 30 23:03 ..
drwxr-xr-x 3 www-data www-data 4.0K Oct 30 22:42 cocktails
drwxr-xr-x 3 www-data www-data 4.0K Oct 30 22:42 ingredients
drwxr-xr-x 2 www-data www-data 4.0K Oct 30 21:40 {cocktails,ingredients,temp}

Creating the temp directory manually solves it

karlomikus commented 4 weeks ago

Interesting, seems like there is an issue with this command: https://github.com/karlomikus/bar-assistant/blob/develop/resources/docker/dist/init.sh#L6

This should create cocktails, ingredients and temp folder.

I'll try to rework it.