question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Symlink does not consider if a file has been modified

See original GitHub issue

This is one of those edge cases nobody likes to think about.

A few things I’ve noticed with symlinks:

  1. If the file.basename is renamed before being piped into symlink, it will generate broken links.
  2. If the file.contents is modified, a symlink is still generated (an error would be preferred).

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 overriding src 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?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
erikkempermancommented, Jun 16, 2017

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 😃

0reactions
dargmueslicommented, May 26, 2018

@phated what’s your recommended way to set a different name for the symlink then, keeping the same target?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What happens to a symbolic link when the original file is ...
If the symlink target /opt/minergate-cli has been re-created when new version of application was installed, the symlink will point to new file.
Read more >
Symbolic link - Wikipedia
In computing, a symbolic link is a file whose purpose is to point to a file or directory (called the "target") by specifying...
Read more >
Strange link in local dir for file being edited in emacs [duplicate]
1 Answer 1 ... It's an interlock: it's created when a buffer is modified in order to allow emacs to warn you when...
Read more >
Stat Symbolic Link : won't show original file modification time
stat calls lstat(2) (by default) to get it's data. As the symlink occupies an inode in the filesystem, it gets the relevant data...
Read more >
How to Create Symbolic Links: A Comprehensive Guide
A symbolic link points to the original file on your system but doesn't contain data in the target file. Consequently, removing the target...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found