Lymphatus / caesium-clt

Caesium Command Line Tools - Lossy/lossless image compression tool
http://saerasoft.com/caesium
Other
358 stars 34 forks source link

Referencing #26 - Bug still exists if output folder is nonexistent #39

Closed bardiir closed 5 years ago

bardiir commented 5 years ago

As described in #26 images do get placed to the root of the file system. But only if the folder specified to -o does not exist.

I would rather expect a creation of the folder in question or an error message.

Lymphatus commented 5 years ago

I would rather expect a creation of the folder in question

This should be the expected behaviour. Can you provide me some more info, like the command you used and the OS?

bardiir commented 5 years ago

You can reproduce this easily as it is docker packed:

$ docker run -ti -v $(PWD):/caesium bardiir/caesium

And then inside the container try to use it on an existing folder - you can see the correct output path in the output of the cli:

/caesium # mkdir exists
/caesium # caesiumclt -q 0 -o exists Box2.obj_180_0000.jpg 
Collecting files...
(1/1) Box2.obj_180_0000.jpg -> /caesium/exists/Box2.obj_180_0000.jpg
46.64 KB -> 39.99 KB [-14.26%]
-------------------------------
Compression completed in 0m0s13ms
46.64 KB -> 39.99 KB [-14.26% | -6.65 KB]

While on a nonexistent folder it will put it into root strangely:

/caesium # caesiumclt -q 0 -o doesnotexist Box2.obj_180_0000.jpg 
Collecting files...
(1/1) Box2.obj_180_0000.jpg -> /Box2.obj_180_0000.jpg
46.64 KB -> 39.99 KB [-14.26%]
-------------------------------
Compression completed in 0m0s10ms
46.64 KB -> 39.99 KB [-14.26% | -6.65 KB]

It's based on alpine - you can find the Dockerfile here: https://github.com/bardiir/caesium/blob/master/Dockerfile

Lymphatus commented 5 years ago

Was an issue with realpath failing on Docker if the output directory was nonexistent. The error was not properly handled, thus the unexpected behaviour. I pushed a fix which tries to create the folder before calling realpath. I run some tests on your docker it seems to work fine. Let me know.