WiiLink24 / food-server

A server designed to run the Demae channel.
MIT License
27 stars 12 forks source link

Add "(PNG Only)" #8

Closed toffee-makes-things closed 2 years ago

toffee-makes-things commented 2 years ago

This is so people dont screw up their database with a half made phantom item.

(I was gonna make it so you could only upload a png but i could not get that to work correctly lmao. I could kinda get good results with FileAllowed(["png"]) but it ended up causing this very issue lol)

toffee-makes-things commented 2 years ago

either im dumb or we would need to change the entire upload system so that flask can correctly check the file type.

so yeah text warning it is

spotlightishere commented 2 years ago

Hm, the resulting format once encoded should be a JPEG, as that's all Demae (and the majority of Wii channels) can handle: https://github.com/WiiLink24/food-server/blob/39350da181d7f54120ac3c76ec9ab8f28a0a3b59/thepantry/encodemii.py#L11-L15 https://github.com/WiiLink24/food-server/blob/39350da181d7f54120ac3c76ec9ab8f28a0a3b59/thepantry/encodemii.py#L40-L42

Is there an error that occurs when uploading a format that isn't a PNG to the web panel?

toffee-makes-things commented 2 years ago

yeah thepantry does not play nice with uploading jpeg. i can double check real quick hold on

toffee-makes-things commented 2 years ago

yeah it does not like jpeg/jpg @spotlightishere

Screen Shot 2022-08-02 at 8 18 38 PM

if you try to delete you can tell it cant convert into a format the Wii likes

toffee-makes-things commented 2 years ago

then you get the half deleted item/restaurant

spotlightishere commented 2 years ago

Hm - looks like the image assets directory for that restaurant wasn't present, leading it to fail deletion. (Maybe a check for the directory's existence prior to unlink would be useful, but hopefully it would never be missing to begin with. We should determine the root cause of its images directory never being created.)

Are you able to find the exception regarding encoding?

toffee-makes-things commented 2 years ago

Hm - looks like the image assets directory for that restaurant wasn't present, leading it to fail deletion. (Maybe a check for the directory's existence prior to unlink would be useful, but hopefully it would never be missing to begin with.)

Are you able to find the exception regarding encoding?

gimme a sec

toffee-makes-things commented 2 years ago

no error in the console. there is no folder for the restaurant but there is a image. maybe it thinks its already converted?

Screen Shot 2022-08-02 at 8 29 02 PM Screen Shot 2022-08-02 at 8 30 00 PM
spotlightishere commented 2 years ago

Hm... I was unable to find any issue related to image encoding, and confirmed that all file types successfully converted to a JPEG (specifically JPEG, PNG, and WebP). If this issue persists, could you please file another issue with its exception?

However, I found that the restaurant was prematurely deleted prior to confirmation - thank you for pointing that issue out! Could you please pull the latest changes (https://github.com/WiiLink24/food-server/compare/d7614e0fbbb4...e0ed5a06ba6f) and confirm this issue no longer occurs?

toffee-makes-things commented 2 years ago

Hm... I was unable to find any issue related to image encoding, and confirmed that all file types successfully converted to a JPEG (specifically JPEG, PNG, and WebP). If this issue persists, could you please file another issue with its exception?

However, I found that the restaurant was prematurely deleted prior to confirmation - thank you for pointing that issue out! Could you please pull the latest changes (d7614e0...e0ed5a0) and confirm this issue no longer occurs?

your code slightly works. it does not throw an exception when deleting a restaurant with a uploaded jpg file. but the record for the restaurant still exists (new restaurant has a ID of 2 when ID 1 is not showing up on thepantry)

toffee-makes-things commented 2 years ago

Hm... I was unable to find any issue related to image encoding, and confirmed that all file types successfully converted to a JPEG (specifically JPEG, PNG, and WebP). If this issue persists, could you please file another issue with its exception? However, I found that the restaurant was prematurely deleted prior to confirmation - thank you for pointing that issue out! Could you please pull the latest changes (d7614e0...e0ed5a0) and confirm this issue no longer occurs?

your code slightly works. it does not throw an exception when deleting a restaurant with a uploaded jpg file. but the record for the restaurant still exists (new restaurant has a ID of 2 when ID 1 is not showing up on thepantry)

i can move this to an issue instead of a PR but im not sure what to name it @spotlightishere

toffee-makes-things commented 2 years ago

Hm... I was unable to find any issue related to image encoding, and confirmed that all file types successfully converted to a JPEG (specifically JPEG, PNG, and WebP). If this issue persists, could you please file another issue with its exception? However, I found that the restaurant was prematurely deleted prior to confirmation - thank you for pointing that issue out! Could you please pull the latest changes (d7614e0...e0ed5a0) and confirm this issue no longer occurs?

your code slightly works. it does not throw an exception when deleting a restaurant with a uploaded jpg file. but the record for the restaurant still exists (new restaurant has a ID of 2 when ID 1 is not showing up on thepantry)

i can move this to an issue instead of a PR but im not sure what to name it @spotlightishere

i have not tried uploading webp yet

toffee-makes-things commented 2 years ago

also sorry for the 50 comments i probably could have condensed that into one lol

spotlightishere commented 2 years ago

(new restaurant has a ID of 2 when ID 1 is not showing up on thepantry)

This is intended - the ID is assigned incrementally by the database (i.e. PostgreSQL):

SELECT last_value FROM shops_shop_code_seq

If the ID is displayed/visibly affects ordering within Demae, or anything continues to refer to ID 1 after deletion, that's definitely worth creating an issue over.

Thank you for checking!