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
add minimize cache directory option #40
Conversation
Type: `String` | ||
Default: `null` | ||
|
||
Set image optimization cache directory, this directory will cache the result of [OptiPNG] and [jpegtran]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those links have no definitions. :)
Very cool, caching the results is definitely a good idea. |
I kinda wish grunt had this built-in, but I guess it's needed as this task can be slow. Can you add a test to make sure it caches it? And use os.tmpdir if available. (it's not available in node 0.8) You also need to fix the merge conflict. |
@sindresorhus Thanks, I'll write some test case. But I think system temp directory can be assigned in imagemin: {
option: {
cache: path.resolve(os.tmpdir(), 'grunt-imagemin-cache')
}
} |
@perfectworks i don't see the point of having an option when we can handle it automatically. |
ping |
1 similar comment
ping |
@sindresorhus I was in vacation last month, and will modify pull request this week. |
ping? I wouldn't mind to do it but I came here every day to see if it's done 😄 |
Sorry for waiting, I've done testcase and use |
|
||
> This directory will cache the result of [OptiPNG](http://optipng.sourceforge.net) and [jpegtran](http://jpegclub.org/jpegtran/). | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any reason this should be an option. Caching can happen transparently.
@perfectworks can you update regarding my comments and fix merge conflict? I want to merge this asap. |
ping |
ping |
Thanks! Landed :) 🍰 |
I've run into problems caused by this feature. Because it creates a dir under /tmp (well, os.tempdir, /tmp for me) with a deterministic name, this means that if multiple users on the same machine attempt to run imagemin, the path will clash. Since the permissions are 644 (again, for me -- this seems like a typical default), this means that the second user will get
I suppose keeping the name consistent is a feature, not a bug (I'm guessing the point is to leave the temp files so they can be accessed as a cache), but then sharing a dirname between users becomes a problem. Perhaps the dir could include $USER? (In my case I hit the problem because I run different sites under different users to separate security concerns. I can work around it by deleting the files from the corresponding accounts, or as root. It could be a major problem, though, for people building on shared hosting.) |
had the same issue |
@haggholm yup, sounds reasonable. |
A bit late, but this plugin might allow you guys to move out the caching functionality from this plugin: |
Having the same kind of problems as @haggholm and @niftylettuce. |
I added a cache for it because imagemin task is too slow.