summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2023-01-29 08:14:39 +0100
committerqkzk <qu3nt1n@gmail.com>2023-01-29 08:14:39 +0100
commit1d37bc0e60f09c0eb4801f86db18d3df34e2ecf2 (patch)
treeafc23d653eff442f8cb162880e72deffc27b6e5c
parentc74b05821c808eb3f8db31cada7dcad1f744e442 (diff)
fix unknow uid/gid prevents file listing
-rw-r--r--development.md9
-rw-r--r--src/fileinfo.rs34
2 files changed, 27 insertions, 16 deletions
diff --git a/development.md b/development.md
index db84371..be0cfd6 100644
--- a/development.md
+++ b/development.md
@@ -366,16 +366,21 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally.
- [ ] Version 0.1.16 : fix completion & filter in tree
+ - [x] FIX: can't parse uid gid if they only exists on a remote machine. See https://serverfault.com/questions/514118/mapping-uid-and-gid-of-local-user-to-the-mounted-nfs-share
+ for a fix.
- [ ] BUG: when searching from tree mode, it only completes with level 1 elements, not nested ones.
- [ ] BUG: when filtering in free mode, only the level 1 matching elements are displayed
- - [ ] BUG: can't parse gid for nfs mounts
- [ ] Version 0.1.50 : safety
- [ ] command::execute in child: prevent it from crashing main app
- [ ] preview of big files (or whatever file) should only read chunk of the file,
- not the whole thing
+ not the whole thing. Previewing a 5gB iso file uses up to 15gB of ram, which will crash any system.
or should it ?
+ Simple solutions:
+
+ - only reads a buffer
+ - limit to xxx filesize
- [ ] Version 0.2.0 : tests
diff --git a/src/fileinfo.rs b/src/fileinfo.rs
index f9306d4..ddeaeea 100644
--- a/src/fileinfo.rs
+++ b/src/fileinfo.rs
@@ -552,25 +552,31 @@ fn convert_octal_mode(mode: usize) -> &'static str {
}
/// Reads the owner name and returns it as a string.
+/// If it's not possible to get the owner name (happens if the owner exists on a remote machine but not on host),
+/// it returns the uid as a `Result<String>`.
fn extract_owner(metadata: &Metadata, users_cache: &Rc<UsersCache>) -> FmResult<String> {
- Ok(users_cache
- .get_user_by_uid(metadata.uid())
- .ok_or_else(|| FmError::custom("extract owner", "Couldn't read uid"))?
- .name()
- .to_str()
- .ok_or_else(|| FmError::custom("extract owner", "Couldn't read owner name"))?
- .to_owned())
+ match users_cache.get_user_by_uid(metadata.uid()) {
+ Some(uid) => Ok(uid
+ .name()
+ .to_str()
+ .ok_or_else(|| FmError::custom("extract owner", "Couldn't parse owner name"))?
+ .to_owned()),
+ None => Ok(format!("{}", metadata.uid())),
+ }
}
/// Reads the group name and returns it as a string.
+/// If it's not possible to get the group name (happens if the group exists on a remote machine but not on host),
+/// it returns the gid as a `Result<String>`.
fn extract_group(metadata: &Metadata, users_cache: &Rc<UsersCache>) -> FmResult<String> {
- Ok(users_cache
- .get_group_by_gid(metadata.gid())
- .ok_or_else(|| FmError::custom("extract group", "Couldn't read gid"))?
- .name()
- .to_str()
- .ok_or_else(|| FmError::custom("extract group", "Couldn't read group name"))?
- .to_owned())
+ match users_cache.get_group_by_gid(metadata.gid()) {
+ Some(gid) => Ok(gid
+ .name()
+ .to_str()
+ .ok_or_else(|| FmError::custom("extract group", "Couldn't parse group name"))?
+ .to_owned()),
+ None => Ok(format!("{}", metadata.gid())),
+ }
}
/// Returns the file size.