Fix tree permissions bug

There was a bug where if you tried to recurse into a directory you didn’t have permission to read the contents of, the error would be ignored.

It now displays the errors.
This commit is contained in:
Benjamin Sago 2017-07-04 17:48:30 +01:00
parent 882ac489ce
commit f4ddbf3849
2 changed files with 12 additions and 2 deletions

View File

@ -209,8 +209,9 @@ impl<'a> Render<'a> {
if let Some(r) = self.recurse { if let Some(r) = self.recurse {
if file.is_directory() && r.tree && !r.is_too_deep(depth.0) { if file.is_directory() && r.tree && !r.is_too_deep(depth.0) {
if let Ok(d) = file.to_dir(false) { match file.to_dir(false) {
dir = Some(d); Ok(d) => { dir = Some(d); },
Err(e) => { errors.push((e, None)) },
} }
} }
}; };

View File

@ -2,40 +2,49 @@
drwxrwxr-x - cassowary  1 Jan 12:34 ├── dirs drwxrwxr-x - cassowary  1 Jan 12:34 ├── dirs
drwxrwxr-x - cassowary  1 Jan 12:34 │ ├── no-xattrs_empty drwxrwxr-x - cassowary  1 Jan 12:34 │ ├── no-xattrs_empty
d--------- - cassowary  1 Jan 12:34 │ ├── no-xattrs_empty_forbidden d--------- - cassowary  1 Jan 12:34 │ ├── no-xattrs_empty_forbidden
│ │ └── <Permission denied (os error 13)>
drwxrwxr-x - cassowary  1 Jan 12:34 │ ├── no-xattrs_one-file drwxrwxr-x - cassowary  1 Jan 12:34 │ ├── no-xattrs_one-file
.rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ └── file-in-question .rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ └── file-in-question
d--------- - cassowary  1 Jan 12:34 │ ├── no-xattrs_one-file_forbidden d--------- - cassowary  1 Jan 12:34 │ ├── no-xattrs_one-file_forbidden
│ │ └── <Permission denied (os error 13)>
drwxrwxr-x - cassowary  1 Jan 12:34 │ ├── no-xattrs_two-files drwxrwxr-x - cassowary  1 Jan 12:34 │ ├── no-xattrs_two-files
.rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ ├── that-file .rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ ├── that-file
.rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ └── this-file .rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ └── this-file
d--------- - cassowary  1 Jan 12:34 │ ├── no-xattrs_two-files_forbidden d--------- - cassowary  1 Jan 12:34 │ ├── no-xattrs_two-files_forbidden
│ │ └── <Permission denied (os error 13)>
drwxrwxr-x@ - cassowary  1 Jan 12:34 │ ├── one-xattr_empty drwxrwxr-x@ - cassowary  1 Jan 12:34 │ ├── one-xattr_empty
│ │ └── user.greeting (len 5) │ │ └── user.greeting (len 5)
d--------- - cassowary  1 Jan 12:34 │ ├── one-xattr_empty_forbidden d--------- - cassowary  1 Jan 12:34 │ ├── one-xattr_empty_forbidden
│ │ └── <Permission denied (os error 13)>
drwxrwxr-x@ - cassowary  1 Jan 12:34 │ ├── one-xattr_one-file drwxrwxr-x@ - cassowary  1 Jan 12:34 │ ├── one-xattr_one-file
│ │ ├── user.greeting (len 5) │ │ ├── user.greeting (len 5)
.rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ └── file-in-question .rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ └── file-in-question
d--------- - cassowary  1 Jan 12:34 │ ├── one-xattr_one-file_forbidden d--------- - cassowary  1 Jan 12:34 │ ├── one-xattr_one-file_forbidden
│ │ └── <Permission denied (os error 13)>
drwxrwxr-x@ - cassowary  1 Jan 12:34 │ ├── one-xattr_two-files drwxrwxr-x@ - cassowary  1 Jan 12:34 │ ├── one-xattr_two-files
│ │ ├── user.greeting (len 5) │ │ ├── user.greeting (len 5)
.rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ ├── that-file .rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ ├── that-file
.rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ └── this-file .rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ └── this-file
d--------- - cassowary  1 Jan 12:34 │ ├── one-xattr_two-files_forbidden d--------- - cassowary  1 Jan 12:34 │ ├── one-xattr_two-files_forbidden
│ │ └── <Permission denied (os error 13)>
drwxrwxr-x@ - cassowary  1 Jan 12:34 │ ├── two-xattrs_empty drwxrwxr-x@ - cassowary  1 Jan 12:34 │ ├── two-xattrs_empty
│ │ ├── user.greeting (len 5) │ │ ├── user.greeting (len 5)
│ │ └── user.another_greeting (len 2) │ │ └── user.another_greeting (len 2)
d--------- - cassowary  1 Jan 12:34 │ ├── two-xattrs_empty_forbidden d--------- - cassowary  1 Jan 12:34 │ ├── two-xattrs_empty_forbidden
│ │ └── <Permission denied (os error 13)>
drwxrwxr-x@ - cassowary  1 Jan 12:34 │ ├── two-xattrs_one-file drwxrwxr-x@ - cassowary  1 Jan 12:34 │ ├── two-xattrs_one-file
│ │ ├── user.greeting (len 5) │ │ ├── user.greeting (len 5)
│ │ ├── user.another_greeting (len 2) │ │ ├── user.another_greeting (len 2)
.rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ └── file-in-question .rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ └── file-in-question
d--------- - cassowary  1 Jan 12:34 │ ├── two-xattrs_one-file_forbidden d--------- - cassowary  1 Jan 12:34 │ ├── two-xattrs_one-file_forbidden
│ │ └── <Permission denied (os error 13)>
drwxrwxr-x@ - cassowary  1 Jan 12:34 │ ├── two-xattrs_two-files drwxrwxr-x@ - cassowary  1 Jan 12:34 │ ├── two-xattrs_two-files
│ │ ├── user.greeting (len 5) │ │ ├── user.greeting (len 5)
│ │ ├── user.another_greeting (len 2) │ │ ├── user.another_greeting (len 2)
.rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ ├── that-file .rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ ├── that-file
.rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ └── this-file .rw-rw-r-- 0 cassowary  1 Jan 12:34 │ │ └── this-file
d--------- - cassowary  1 Jan 12:34 │ └── two-xattrs_two-files_forbidden d--------- - cassowary  1 Jan 12:34 │ └── two-xattrs_two-files_forbidden
│ └── <Permission denied (os error 13)>
drwxrwxr-x - cassowary  1 Jan 12:34 └── files drwxrwxr-x - cassowary  1 Jan 12:34 └── files
.rw-rw-r-- 0 cassowary  1 Jan 12:34  ├── no-xattrs .rw-rw-r-- 0 cassowary  1 Jan 12:34  ├── no-xattrs
.--------- 0 cassowary  1 Jan 12:34  ├── no-xattrs_forbidden .--------- 0 cassowary  1 Jan 12:34  ├── no-xattrs_forbidden