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

Way to follow symlink? #240

Closed
nerdfever opened this issue Jan 5, 2024 · 3 comments
Closed

Way to follow symlink? #240

nerdfever opened this issue Jan 5, 2024 · 3 comments

Comments

@nerdfever
Copy link

Is it possible to add a method to follow a symlink manually (a button or right-click option)?

Often I right-click on a symlinked directory on my desktop, choose qdirstat, and see something like:

image

It would be great if I could click on the link, a button, or something to make qdirstat follow the link and run on the target.

@shundhammer
Copy link
Owner

shundhammer commented Jan 6, 2024

If it's just for following a symlink passed as a directory to read on the command line (which is what the .desktop file magic actually does), that should be easy enough; it would be fully automatic, though.

Stay tuned.

@shundhammer
Copy link
Owner

shundhammer commented Jan 6, 2024

[sh @ uruk] ...src/qdirstat/src 64 % file follow* nirvana
followme:  symbolic link to /work/home/sh/src
followme2: symbolic link to followme
nirvana:   broken symbolic link to ../../nowhere

[sh @ uruk] ...src/qdirstat/src 65 % qdirstat followme2

QDirStat-valid-symlink

[sh @ uruk] ...src/qdirstat/src 66 % qdirstat nirvana  

QDirStat-broken-symlink

This will be included in the upcoming QDirStat 1.9 release.

@shundhammer
Copy link
Owner

shundhammer commented Jan 6, 2024

When I read this issue first, I thought it was about generally following symlinks from a an in-memory directory tree. I had thought about that in the past several times, and some day it will probably come. Here are my thoughts about that - just so they don't get lost:

Following Symlinks in General

Unfortunately, that's a lot more difficult than it sounds.

A symlink can point to another symlink; that's one issue (and it's quite common). I am not sure if such a function should follow a chain of symlinks all the way to the target, or just one level; if there is a problem in that chain such as no permissions for one of the intermediate directories, it would be impossible to find out. But let's say the normal operation should follow a chain of symlinks to the final target.

Another problem is that QDirStat usually only reads a subtree of a complete filesystem's directory hierarchy; for example /home/kilroy if that user starts it. But when that subtree contains a link outside of the tree like /home/kilroy/project -> /home/common/projects/foo, then what? It would have to report to the user that this symlink cannot be followed, or offer to read the complete /home hierarchy.

And if that destination link is also a link, pointing outside of that other tree as well, an even larger tree would have to be read.

Okay, part of this could be alleviated by not using QDirStat's in-memory tree, but reading directly from disk for such calls. But that would open a host of other problems if the in-memory tree and the on-disk tree are no longer in sync (i.e. if the in-memory tree has become outdated).

Another issue is the user interface. Right now, the 'Details' panel on the right already shows a symlink's (direct) target, and when it's a bit longer (e.g. a full path), it's underlined showing that it's clickable. Not sure if that's in the last released version 1.8.1 yet, but it's in the current development version which will become 1.9 soon.

When clicked, right now it shows the full target in a pop-up. But that could be extended; it could be turned into a pop-up menu with the full path on top, and then menu options like "Follow link (first level)" and "Follow link (all levels)".

And then... well, exactly what? Probably navigate in the tree to the target, very much like when you click on a treemap tile. Of course that would throw the user completely out of context (similar to clicking on a treemap tile - where that is expected, though), and it wouldn't be trivial to go back to the previous location.

Yes, we now have a browser-like history buttons ("back" and "forward"), but that goes back just to the previous directory, not to the exact item; the symlink in this case. You'd have to scroll down the list to get to the symlink. Not the end of the world, but annoying.

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

2 participants