Skip to content

Use tokio::fs in HostScanner #1130

Description

@Molter73

Since HostScanner runs as a tokio task, we should not be using std::fs operations on it, since it will block the underlying thread and prevent the tokio scheduler from properly doing its job, we should instead prefer using tokio::fs for asynchronous filesystem operations.

The main change for this will be that HostScanner has two RefCell fields, borrowing these results in guards that are not Send, meaning they can't be used through a .await call. We will need to replace them with RwLock or Mutex.

While we are at it, we probably also want to change calls to PathBuf::is_dir, PathBuf::is_file and PathBuf::metadata to instead use a single tokio::fs::metadata call and propagate the result, the individual calls to the PathBuf methods trigger a call to stat under the hood for each occurrence.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions