AspectUnk / russh-sftp

SFTP subsystem supported server and client for Russh
Apache License 2.0
64 stars 21 forks source link

Read_dir unable to read link file #17

Closed TheBlindM closed 9 months ago

TheBlindM commented 9 months ago

image image

        let entries = sftp.read_dir(select_path).await?;

        let mut files: Vec<_> = entries
            .into_iter()
            .map(|entry| {
                info!(
                    "name:{} isLink:{}",
                    &entry.file_name(),
                    entry.file_type().is_symlink()
                );
                let attributes = entry.metadata();

                let r#type = match attributes.file_type() {
                    FileType::Dir => "dir",
                    FileType::File => "file",
                    FileType::Symlink => "symlink",
                    FileType::Other => "other",
                };
                let select_path_copy = select_path_copy.clone();
                FileInfo {
                    path: Option::from(select_path_copy + &entry.file_name()),
                    name: Option::from(entry.file_name()),
                    size: attributes.size,
                    r#type: r#type.to_string(),
                    modify_date: attributes.mtime.map(|mtime| {

                        let date_time = Utc.timestamp(mtime as i64, 0);
                        date_time.format("%Y-%m-%d %H:%M:%S").to_string()
                    }),
                }
            })
            .collect();
AspectUnk commented 9 months ago

Now it is fixed. Will be published in the next version. Thank you