-
-
Notifications
You must be signed in to change notification settings - Fork 437
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
Add no-windows-permissions feature, to disable access/owner checks #484
Conversation
Codecov Report
@@ Coverage Diff @@
## master #484 +/- ##
=======================================
Coverage 84.45% 84.45%
=======================================
Files 36 36
Lines 3378 3378
=======================================
Hits 2853 2853
Misses 525 525 Continue to review full report at Codecov.
|
Having this behind a feature flag seems like a good compromise until we have a better solution, which I guess should be possible from #475 (comment)
What do you think about having all the values as |
false works for me, done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, just a few changes. Plus could also handle/suppress the unnecessary warnings.
src/meta/windows_utils.rs
Outdated
group_write: false, | ||
group_execute: false, | ||
|
||
other_read: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make this as false as well.
src/meta/windows_utils.rs
Outdated
@@ -13,6 +13,32 @@ use super::{Owner, Permissions}; | |||
|
|||
const BUF_SIZE: u32 = 256; | |||
|
|||
#[cfg(feature = "no-windows-permissions")] | |||
pub fn get_file_data(path: &Path) -> Result<(Owner, Permissions), io::Error> { | |||
let owner = Owner::new("?".to_string(), "?".to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to make owner optional in the struct in case of windows(we could probably have #473 added in after that).
Also have the user/group as -
with a greyish colors simliar to when there are no permissions. Something like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a great idea -- I'll get on it today. I may split the no-windows-perms stuff into a separate .rs file, so that it's easier to cfg out stuff to avoid warnings too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(sorry, life got in the way this past week. will get to it when I can!)
I tried this locally combined with #473 (after fixing a tiny merge conflict) and it makes a huge difference. Running lsd in a particular directory consistently took about 8 seconds before. Now it takes 479 milliseconds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one more question, as this is added as a build-time feature, should we need to release a new binary for this feature?
and, @vvuk did you have some cycle to update this PR again, and we can make it happen after the discuss resolved?
or I can help to send a patch if you did not have time.
#[cfg(all(windows, feature = "no-windows-permissions"))] | ||
let (owner, permissions) = (None, None); | ||
|
||
#[cfg(windows)] | ||
#[cfg(all(windows, not(feature = "no-windows-permissions")))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about checking this feature inside windows_utils.rs
, so that we can keep checking unix/windows
and drop the necessary to set owner
and permissions
as Optional, and keep the logic of Windows inside windows_utils.rs?
@@ -37,10 +44,18 @@ impl<'a> From<&'a Metadata> for Owner { | |||
|
|||
impl Owner { | |||
pub fn render_user(&self, colors: &Colors) -> ColoredString { | |||
colors.colorize(self.user.clone(), &Elem::User) | |||
if self.user.len() == 0 { | |||
colors.colorize("?".to_owned(), &Elem::User) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as #484 (comment) mentioned, this should be -
, right?
I don't at the moment -- if you're able to take it over, please do! |
I suggest closing this one since #882 is merged (adding |
Doing this on Windows is very slow; this adds a feature flag to disable doing these checks, making lsd as fast as any other directory listing tool. Without this, running
lsd
on a directory with ~100 files takes around 600ms. With this feature enabled, it takes 40ms.Adds a bunch of compilation warnings unfortunately; the structure could be better to clean this up.
TODO
cargo fmt