-
Notifications
You must be signed in to change notification settings - Fork 12
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
Moving/copying/removing a symbolic link #6
Comments
I tried to put together something resembling what I think an API with support for symlinks might look like, without changing the semantics of anything that already existed. The commit shows:
|
Sorry I haven't replied yet. This issue is very interesting to me, but
unfortunately my 6mo old spilled half a cup of coffee on my laptop a few
days ago and it's taking me a bit to set up my new computer with NixOS.
|
Amusingly enough, I think I may have destroyed my own computer, too, while I was in the middle of performing the migration to |
Okay, I'm back and ready to look at a design which incorporates symlinks in some way. Usecase / Problem StatementFirst, some definitions:
The goal of this issue should be to use absolute paths as opposed to cannonicalized paths as the base type (but Technical Solution
Part 2I think the above should theoretically work for what we want -- now what to do with the rest of the API. If the following can be zero cost they would be nice:
Other thoughts are welcome! |
Sounds like part of what you're describing is Path::clean (stdlib PR). Absolute paths would solve this problem and some others. What you've got drafted there at the time of me writing this sounds like a bit of a wild mix of canonicalization and cleaning; I'm not sure about Windows, but on Unix I think (note: well, okay, that's only true for CLI args. For paths in config files, some form canonicalization is needed so that the current directory does not impact resolution) |
this and this are particularly enlightening. Fully supporting windows is not easy and I think I would want to wait until at least Edit: the first link was only interesting because they said that |
@kennytm I followed your comments on the rust issue and I'm wondering what your thoughts are for this issue. The basic use case: we want "absolute paths for files that exist" -- but they are allowed to have symlinks inside. In particular, do you think the technical solution I gave will work for windows? |
agh, I hate my life
that actually makes sense and makes me very sad. |
So, thinking a little more about this, I don't think there is really any value in allowing So my suggestion: only allow (multiple) The issue of resolving the wrong path doesn't exist when |
I construct paths with interior |
good point. I think treating it semantically is probably the best course of action, agreed? |
See #11, would love any feedback! |
Define semantically? (Lexically?) I alluded to this in an edit to one of my previous posts, but I'm beginning to think that automatic normalization of any form can be hazardous. There are times when straight up canonicalization is best, and there are other times when cleaning first before canonicalization is best. That said, I certainly will feel a lot more comfortable using the library when it isn't instantly following every symbolic link; so I do welcome any change to that effect. |
This should be solved as of #11. Please comment! |
solved > 0.4.0 |
(I wish GitHub provided a better way to have discussion other than opening a bug report)
Let's talk symlinks.
I have an application which has historically taken the easy way out of path management by changing the current directory. In moving away from this setup towards a more principled design, I considered using
path_abs
as a means of leveraging the type system to ensure that I don't accidentally leave behind any lingering relative paths.Reviewing the documentation, however, it is evident to me that my mental model of symlinks differs from that of the library. Of course, this is to be expected; I understand that PathAbs is opinionated, and that our ideas will inevitably clash somewhere.
But with regard to symlinks specifically, I find the model presented by this crate to be dangerous, and quite scary! I'd like to hear your point of view on this, and I wonder if there is something I am missing.
I'll describe these clashing models by making analogy to Rust's borrow semantics.
To me:
Box<_>
type. It has a unique owner (its "true" parent) and that's the only way you can move or delete it.Arc<_>
type. It may have multiple owners via hard links, and dies when the last link vanishes.*mut _
type. It can change data belonging to its target, but only if you explicitly dereference it (by joining another path component). The pointer itself does not own its target, and its target might not even exist.In PathAbs:
What do you think of this? Do you disagree with this risk about deleting a symlink? Is there room in PathAbs for symlinks to live as first class citizens? Am I asking too many questions? 😛
The text was updated successfully, but these errors were encountered: