Skip to content
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

No such file or directory for symlinks whose targets don't exist #16

Closed
vjpr opened this issue Jun 16, 2019 · 6 comments
Closed

No such file or directory for symlinks whose targets don't exist #16

vjpr opened this issue Jun 16, 2019 · 6 comments

Comments

@vjpr
Copy link

vjpr commented Jun 16, 2019

If a symlink points to a file that doesn't exist, it should not break the diff.

It looks like symlinks are not handled well in general.

@gliviu
Copy link
Owner

gliviu commented Jul 1, 2019

It looks like symlinks are not handled well in general.

Aside 'symlink does not exist' is it any other issue that you saw? Please be speciffic. There has been a lot of effort added to properly support symlinks in this project.

If a symlink points to a file that doesn't exist, it should not break the diff.

This was a design decision. If you know you have broken symlinks you can always use --skip-symlinks option.
What you probably want is a 'ignore broken symlinks' option which was not implemented because it was never requested.

@szpak
Copy link

szpak commented Dec 16, 2019

Recently I have encounter the same issue with a broken symlink (1.8.0):

$ dircompare.js -c -lrd /home/foobar/Documents/ /mnt/foo/home/foobar/Documents/
Error occurred: Error: ENOENT: no such file or directory, stat '/home/foobar/Documents/broken-symlink'
    at Object.statSync (fs.js:855:3)
    at /home/foobar/binary/dir-compare/node_modules/dir-compare/compareSync.js:28:35
    at Array.forEach (<anonymous>)
    at getEntries (/home/foobar/binary/dir-compare/node_modules/dir-compare/compareSync.js:19:20)
    at compare (/home/foobar/binary/dir-compare/node_modules/dir-compare/compareSync.js:83:37)
    at compare (/home/foobar/binary/dir-compare/node_modules/dir-compare/compareSync.js:141:17)
    at Object.compareSync (/home/foobar/binary/dir-compare/node_modules/dir-compare/index.js:39:5)
    at /home/foobar/binary/dir-compare/node_modules/dir-compare/dircompare.js:113:38
    at Promise._execute (/home/foobar/binary/dir-compare/node_modules/bluebird/js/release/debuggability.js:272:9)
    at Promise._resolveFromExecutor (/home/foobar/binary/dir-compare/node_modules/bluebird/js/release/promise.js:475:18)
    at new Promise (/home/foobar/binary/dir-compare/node_modules/bluebird/js/release/promise.js:77:14)
    at run (/home/foobar/binary/dir-compare/node_modules/dir-compare/dircompare.js:112:35)
    at Object.<anonymous> (/home/foobar/binary/dir-compare/node_modules/dir-compare/dircompare.js:144:1)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)

It helped me to find some broken symlinks ;-), however, in some corner cases I had to exclude proper paths (or ignore symlinks at all), e.g.:

$ ll /home/foobar/.mozilla/firefox/some-profile/lock
lrwxrwxrwx. 1 foobar foobar 19 Dec 17 00:30 /home/foobar/.mozilla/firefox/some-profile/lock -> 192.168.1.10:+15293

In a situation the implementation is not overly complicated it would be useful to have an option to ignore broken symlinks assuming they are broken on the both side.

@gliviu
Copy link
Owner

gliviu commented Dec 19, 2019

I think this issue will be resolved if we implement #19.
If dircompare is used with default comparison options (ie. dircompare a b) it will crash as above.
If it uses new 'symlink aware' options (ie. `dircompare --compare-symlinks a b') it will include symlink differences in the report (including broken symlinks).

What do you think?

@szpak
Copy link

szpak commented Dec 20, 2019

I'm not sure if crash is the best behavior for broken symlinks. It happens occasionally to break a link (to make it unresolvable) and then it is required to disable all links processing in the comparison . Maybe it could report it as "missing" if a broken link on one side, but is resolvable on the other?

@gliviu
Copy link
Owner

gliviu commented Dec 21, 2019

Agreed, better to avoid crash by default.
I like the idea of reporting 'missing'. Still we can treat it as a special type of entry.

# broken symlink on the left, regular file on the right
[/] a1.txt->missing(broken symlink)
[/] missing->a1.txt(file)
Entries are different
total: 2, equal: 0, distinct: 0, only left: 1, only right: 1

# broken symlink on both sides
[/] a1.txt->missing(broken symlink)
[/] missing->a1.txt(broken symlink)
Entries are different
total: 2, equal: 1, distinct: 0, only left: 0, only right: 0

@szpak
Copy link

szpak commented Dec 22, 2019

[/] a1.txt->missing(broken symlink)
[/] a1.txt->missing(broken symlink)
[/] missing->a1.txt(broken symlink)

It sounds good!

gliviu added a commit that referenced this issue Jan 1, 2020
gliviu added a commit that referenced this issue Jan 11, 2020
@gliviu gliviu closed this as completed Jan 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants