Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple invocations collide in tmpdir, crash #183

Closed
paulp opened this issue Dec 29, 2019 · 2 comments
Closed

multiple invocations collide in tmpdir, crash #183

paulp opened this issue Dec 29, 2019 · 2 comments

Comments

@paulp
Copy link

paulp commented Dec 29, 2019

Steps To Reproduce The Error

Invoke imageoptim a second time on the same machine.

Expected Behaviour

Both runs complete successfully.

Actual Behaviour

When the first one completes, it expunges the temporary directory which both processes are using. The other immediately crashes:

i Running ImageOptim...
! ENOENT: no such file or directory, stat '/var/folders/ct/vwmp17px5lq96n7vrqf8fhqh0000gn/T/imageoptim-cli/image123.jpg'
! Please raise an issue at https://github.com/JamieMason/ImageOptim-CLI/issues    

Version Numbers or N/A

N/A

Help Needed

Invocations should each use a unique temporary directory. I'm unfamiliar with this language, but on the command line you can see what mktemp does:

% /usr/bin/mktemp -d
/var/folders/ct/vwmp17px5lq96n7vrqf8fhqh0000gn/T/tmp.oe1HyPEd

The string oe1HyPEd in this example is there to prevent bugs of this kind.

Fixing this probably only requires a tweak to this line but at the moment I don't have time to familiarize myself enough to send a PR. If needed I will come back to this. Thanks.

@danmostudco
Copy link

Just to comment on this, I've had a similar problem when adding multiple images. I've been using it in a pre-commit hook using husky > lint-staged > and then calling image-optim. Anytime I have multiple jpg's the process seems to fail.

However, the the cli seems to work with multiple pngs. Here are the scripts I call

"imageoptim": "yarn imageoptim:gif && yarn imageoptim:jpg && yarn imageoptim:png", "imageoptim:gif": "imageoptim \"public/**/*.gif\"", "imageoptim:jpg": "imageoptim \"public/**/*.jpg\"", "imageoptim:png": "imageoptim --no-imageoptim --imagealpha \"public/**/*.png\"",

Sometimes I don't get the error, and instead it appears I get stuck in a loop or sorts until I kill the process. Unsure if this helps but figured I would chime in. Thanks!

@JamieMason
Copy link
Owner

This should hopefully be fixed in 3.0.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants