yamipa icon indicating copy to clipboard operation
yamipa copied to clipboard

Images are not usable after downloading them using itzg/docker-minecraft-server

Open senolem opened this issue 1 year ago • 7 comments

Hello, I have a server hosted in a docker-compose using the itzg/docker-minecraft-server image When I download images it works and places them correctly in yamipa's images folder, but then when using /image give or /image list the image simply doesn't exists image image

Any idea what's going on here? the data folder is mounted between the host and the container, but that shouldn't be an issue... thanks

senolem avatar Feb 08 '24 23:02 senolem

Looks like it works now, the image would only show up in the list after rebooting the container. I don't know if this plugin listen for system events for new files or if it's checked every time commands are called, maybe that's a clue? image I tried checking file permissions and ownership without restarting the container (red arrow) but looks they're all the same.

senolem avatar Feb 10 '24 02:02 senolem

Hello @senolem,

Could you set verbose: true in the Yamipa configuration file and paste the server logs here?

josemmo avatar Feb 12 '24 18:02 josemmo

image

nothing interesting...

but something is odd. it can detect that there is already a file with the same name

image

senolem avatar Feb 13 '24 16:02 senolem

by reading the code, my guess would be that something is going on with the destPath we use for the new image. I did not edited the images-path value, neither allowed-paths It would be interesting to see what destPath looks like in the downloadImage() function. What is odd is that it would mean storage.isPathAllowed() does not return false when downloading an image, but does when trying to fetch the file in the ImageFileArgument class when using /image place, and when fetching image names in getFilenames(), called when using /image list

If that's the case, I would suggest displaying a warning when an unallowed path stored in the files array is detected, for example in getFilenames() we should display a warning if isPathAllowed(filename, sender) returns false.

Could you give me directions on how to build the plugin? I never coded java before.

senolem avatar Feb 13 '24 17:02 senolem

You can build the project by cloning the repository and opening it in IntelliJ IDEA. Then, click on the Maven tab on right on the screen and double click "Lifecycle" > "Package". This should have created a JAR file on the "target" directory inside the project.

I don't think it's related to the ImageStorage#isPathAllowed() method, as you should have seen debug logs on the server console at download regardless of your plugin configuration.

This must have something to do with Java's WatchService class and inotify on Linux (see this link). When I find some time, I'll try to reproduce the bug on a container.

josemmo avatar Feb 13 '24 18:02 josemmo

Thanks I managed to build it.

if (isPathAllowed(filename, sender)) { response.add(filename); } else { LOGGER.warning("Unallowed path detected in the registered files map"); }

I tried to add a warning but it doesn't show up, sorry for the wrong assumption.

senolem avatar Feb 13 '24 18:02 senolem

Hi, @senolem!

Could you verify that this issue is now fixed in the v1.3.2-SNAPSHOT pre-release version of Yamipa?

josemmo avatar Mar 28 '24 16:03 josemmo

@senolem Would you like to test it or write the status here? (with Minecraft version <1.20.6)

RedstoneFuture avatar Oct 05 '24 14:10 RedstoneFuture