gulp-changed-in-place icon indicating copy to clipboard operation
gulp-changed-in-place copied to clipboard

Cache is not updated with new files

Open mxl opened this issue 7 years ago • 4 comments

As @jrubins noted in his comment when passing cache that does not contain some files (including cases when cache is empty) these files are not passing because of this condition:

    if ((!currentHash && firstPass) || (currentHash && currentHash !== newHash)) {
      stream.push(file);
    }

I think it will be more intuitive if we replace firstPass option with force:

    if (!currentHash || currentHash !== newHash || force) {
      stream.push(file);
    }

So file will be processed if:

  • it's a new file (!currentHash);
  • it has been changed (currentHash !== newHash)
  • its processing is forced.

This behavior seems to be more logically consistent than the current one.

If you agree with my suggestion then I'm ready to submit a PR.

WDYT?

mxl avatar May 10 '17 14:05 mxl

@alexgorbatchev WDYT about that?

mxl avatar Sep 28 '17 21:09 mxl

@mxl I think that

    if (!currentHash || currentHash !== newHash || force) {
      stream.push(file);
    }

Will always pass if force is true, which isn't intended effect. The idea behind firstPass is to ensure that the files are triggered once during the boot sequence. If you are storing the cache, it sounds to me like your files are also cached. If you delete the files but keep the cache, you need to regenerate the files by emptying out the cache as well.

Could you help me to understand the use case that you want to address here?

alexgorbatchev avatar Oct 02 '17 17:10 alexgorbatchev

@alexgorbatchev I agree that force option is odd because this will disable the plugin. But still default firstPass: false also produces strange behavior, because new files are not added to a cache. So I always need to pass firstPass: true to update a cache with new files. I suggest to remove firstPass option:

if (!currentHash || currentHash !== newHash) {
  stream.push(file);
}

or rename it to skipNewFiles with false default value:

if (!(currentHash || skipNewFiles) || currentHash !== newHash) {
  stream.push(file);
}

Currently firstPass option name and description:

Makes gulp-changed-in-place pass through all files once on the first run.

are misleading because in fact we need to pass it always to update a cache with new files.

mxl avatar Oct 04 '17 12:10 mxl

@alexgorbatchev ping

mxl avatar Oct 30 '17 06:10 mxl