-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
Symlink does not consider if a file has been modified #245
Comments
Currently I guess it's reasonable to expect this to work, i.e. that the basename change only applies to the source but not the target of the link, but not sure how that could be implemented. I suppose we could examine the vinyl's We've looked at detecting changes to the contents, specifically to reflect accurate modification times in the vinyl's But at the time I did not see a clean way to do this. It's not enough to look at just overwrites of the |
In my own implementation I simply added a checksum to the vinyl object and use the first I don't see how detecting the target would be a problem? wouldn't it always be the first history entry, resolved if that itself is a symlink? Any other filename in the chain cannot be trusted to point to a physical file/inode. Even if a file is created on the fly, as with something like |
I think -- but would need a bit more time to figure out for sure -- that it might be tricky in multi-stage pipelines like this: gulp.src('in/foo')
.pipe(rename({basename: 'bar'}))
.pipe(gulp.dest('out')) // writes out/bar
.pipe(rename({basename: 'qux'}))
.pipe(gulp.symlink('out')) // expect symlink from out/qux to out/bar, not to in/foo Pretty contrived though, I admit :-) |
Ahh, I never thought about continuing to use the stream after a I would class that as an edge case though, which can easily be fixed by either the user A. piping to another stream which pushes a new file object (with gulp.src('in/foo')
.pipe(rename({basename: 'bar'}))
.pipe(gulp.dest('out')) // writes out/bar
.pipe(rename({basename: 'qux'}))
.pipe(gulp.symlink('out', {basename: (file) => {return 'bar';}})) // write /out/qux -> out/bar If As for the other problem of symlinking to memory, it's a shame the buffer object doesn't emit events on write. It would make tracking changes a lot easier. I wonder if issuing a warning if |
With a dedicated option, the There might be valid reasons to subclass / patch the Buffer class, such as the mtime discussion I linked earlier. But if the goal is just to prevent |
In the example given, the second How would the Subclassing / patching the Buffer class will likely lead to problems down the road. As in plug-ins will not be able to call |
@twifty There is some work going on around symlinks at the moment -- I'm going to keep your suggestions in mind and hopefully we can end up with something that makes sense for most scenarios! |
@twifty Yeah, if any patching of Buffer is done things would have to be wrapped in the vinyl setter, here: |
I guess I should chime in here:
I'm going to mark this as "enhancement" because of item 2 |
@phated what's your recommended way to set a different name for the symlink then, keeping the same target? |
Going over this thread again, I don't believe there is a good way to detect/guess this. I'm going to change This also means that this works vfs.src('in/foo')
.pipe(vfs.symlink('out')) // will link to in/foo
.pipe(vfs.symlink('something')) // will link to out/foo |
This is one of those edge cases nobody likes to think about.
A few things I've noticed with symlinks:
symlink
, it will generate broken links.Admittedly, I'm still using v2.4.4, but I don't see anything in master to suggest this has been fixed.
In my use case, I'm wrapping gulp to play nicely with a PHP framework. I've had to override
dest
to auto rename files and to log written filenames. One of the problems I'm trying to overcome is that if file contents have not been modified, they must be linked rather than copied. As it stands I have no way to detect this without also overridingsrc
and possibly hashing the contents.A great solution would be to add a
revision
property to the file object. This would start out at 0 and be increased any time the content is modified. This will also help solve problem (2) above.In the mean time, can anybody suggest an ideal workaround for detecting changed contents?
The text was updated successfully, but these errors were encountered: