jgable / gulp-cache

A cache proxy task for Gulp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Images had returned from the cache are corrupted

frenzzy opened this issue · comments

Launch gulpCacheTest for the first time:

> gulp images
[gulp] Using file C:\gulpCacheTest\Gulpfile.js
[gulp] Working directory changed to C:\gulpCacheTest
[gulp] Running 'images'...
[gulp] gulp-imagemin: ? hackers-movie-poster.jpg (saved 1.3 kB)
[gulp] gulp-imagemin: ? movie-night_t_nv.jpg (saved 70.4 kB)
[gulp] gulp-imagemin: ? scotch_egg.jpeg (saved 3.2 kB)
[gulp] gulp-imagemin: ? exitbuddy.png (saved 3.3 kB)
[gulp] gulp-imagemin: ? slimer1.jpg (saved 11.6 kB)
[gulp] gulp-imagemin: ? road-house-patrick-swayze-31226564-2560-1851.jpg (saved 31.7 kB)
[gulp] Finished 'images' in 4.57 s

Windows Photo Viewer shows all these pictures well
But if it launch images task for the second time:

> gulp images
[gulp] Using file C:\gulpCacheTest\Gulpfile.js
[gulp] Working directory changed to C:\gulpCacheTest
[gulp] Running 'images'...
[gulp] Finished 'images' in 377 ms

Windows Photo Viewer can't open this picture because the file appears to be damaged or corrupted
P.S.: OS Win 7 x64, node v0.10.28, gulp-cache v0.1.3 (on v0.1.9 the same result)

Hmm... I don't have a windows machine to test this out with but I can check on my machine and see if I can reproduce.

I can confirm with the latest version the files are corrupted. It might be something to do with the way we are serializing the data into a string and back into a buffer when saving/restoring. I'll try to take a look this evening on getting a fix together.

I think I figured it out. I switched back to saving the contents as a buffer and restoring it as such. Seems to have fixed the issue.

The fix is published as 0.1.10 on NPM. Update to that version and try the gulp images task again to test.

Tested on v0.1.11 -> works well
Thank you, @jgable!