Repository: pkolaczk/fclones (language: rust)

Issue:
fclones:  warn: Permission denied (os error 13)
Would be nice to report which file caused permission denied.


Discussion / hints:
It generally does warn which file causes permission denied. Can you provide more context, reproduction steps?
Hm usually I get filename if i don't have r/w permission.  Perhaps it was an immutable file with chattr +i.  
It's built on aarch64.  Filesystem was ext4.  I can't think of other info to report, sorry.
Which fclones command was that? Did you get it when grouping or when removing duplicates?
fclones group . > dupes.txt
I'll try to recreate the behavior.  Thanks for your attention.  And thanks for the great software.
alright trying it again on a big merge (3 million files) i see
`[2022-08-20 02:48:37.970] fclones:  info: Started grouping

[2022-08-20 02:57:21.701] fclones:  warn: Permission denied (os error 13)

[2022-08-20 02:57:21.702] fclones:  warn: Permission denied (os error 13)

[2022-08-20 02:57:21.768] fclones:  warn: Permission denied (os error 13)

[2022-08-20 02:57:21.768] fclones:  warn: Permission denied (os error 13)`

Before running it i did a chown -R user:user * to ensure that I owned all the files.
There ought to be some tweak to report what files are problematic.  I don't speak Rust though.
Thank you for the logs, that's very useful. I conclude those warnings come from the directory walking code (walk.rs). Probably a missing `map_err` somewhere to provide error context.

Fix patch:
diff --git a/src/file.rs b/src/file.rs
index 2715e64..c4e037d 100644
--- a/src/file.rs
+++ b/src/file.rs
@@ -290,7 +290,12 @@ pub struct FileMetadata {
 impl FileMetadata {
     pub fn new(path: &Path) -> io::Result<FileMetadata> {
         let path_buf = path.to_path_buf();
-        let metadata = fs::metadata(&path_buf)?;
+        let metadata = fs::metadata(&path_buf).map_err(|e| {
+            io::Error::new(
+                e.kind(),
+                format!("Failed to read metadata of {}: {}", path.display(), e),
+            )
+        })?;
         #[cfg(unix)]
         let id = FileId::from_metadata(&metadata);
         #[cfg(windows)]


Test patch: