-
Notifications
You must be signed in to change notification settings - Fork 326
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
Sort By Change Time #226
Sort By Change Time #226
Conversation
I jumped the gun a bit, there seems to be instances where some files aren't added to the file list (I'm guessing the stat check is failing?). Looking into it. |
On the latest commit, I'm falling back to ModTime if ChangeTime cannot be determined. That seems to fix the missing files issue. I'll keep using it to see if I ferret out any weird issues. |
@kmwenja Sorry for late reply and thanks for contributing. It says in the wiki page that it is best to open an issue first only because I don't want to waste other people's time working on a patch that is not to be merged. So it is ok for me if it is ok for you too. I am usually hesitant to add a new dependency but this one seems like a clean and stable library so I think it is ok. Looking at the code without trying, have you considered using |
c1614cd
to
436c2b1
Compare
Awesome! I've gone ahead and added access time sorting as well as updated the info types (it was previously still showing ModTime() on the ui). |
Oh, almost forgot. I also rebased the commits I was working on so it's one single commit now. |
47dde23
to
dc6c235
Compare
Latest commits are just tiny cleanups. Should be good to look at now. |
@kmwenja I just realized we are now doing an extra stat call for each file. We already have a stat call just above which should already have this information. Is it not possible to get the time information from that file info and get rid of the redundant stat call? Looking at the library code, I could not find a way to do so. We somehow need an exported version of the function Also currently we seem to be using |
Good point, nice catch. There is actually an exported function here: https://godoc.org/github.com/djherbis/times#Get. Let me see what I can do with it. |
- Add access time and change time as sort by types. This is powered by github.com/djherbis/times. - Fall back to modification time if access time and change time cannot be determined. - Add `sa` and `sc` as default bindings for sort by access time and sort by change time respectively. - Add access time and change time to info types allowing them to be displayed by the file list in the ui
dc6c235
to
9c216d0
Compare
@gokcehan Updated. |
@gokcehan Some cautionary notes on the times' README:
|
@kmwenja It seems like a confusing note and I'm not sure what it means. I hope it does not panic in windows. |
@kmwenja Also thanks for the patch. |
Woah! This was awesome. Thanks for letting me! |
Sort file list by file change time. Slightly dirty, no tests.
This probably doesn't follow contributing rules (PRs are for bugfixes according to the contributing guidelines) but I didn't know the best way to raise this. See details below.
Just recently run into lf (by seeing it on @LukeSmithxyz's site, thanks btw) and I was hooked by the very fact that it's written in Go so I decided to try it out.
Then I hit the most curious of walls; for some reason ranger was sorting files by time in a different way to lf. Soon after I realized I was using
oc
on ranger which sorts by change time while lf's only time sort was usingos.FileInfo.ModTime
(aka modification time). On a whim, I decided to see if I could implement change time sorting.It's weird that go stdlib doesn't expose file change times so I sought out an answer (DDG to the rescue), first landing on an SO question and then to https://github.com/djherbis/times which at least attempts to be cross-platform. Some quick hacks later and the code below was born (BTW this was very quick, a testament to how organized this codebase is).
I'm presuming that I've probably overstepped by starting a PR directly, not to mention introducing a new lib and not writing tests. But I thought starting an issue while I already had working code would be a roundabout way of getting here and I wanted to see if the code could speak for itself.
Is this something that can get merged in and if so what would I need to do to clean it up to something merge-able?