Rename Message::Progress::file field to dir

This commit is contained in:
Lukas Wirth 2024-01-16 10:43:33 +01:00
parent 1ceb2ea414
commit 398150827f
3 changed files with 11 additions and 17 deletions

View file

@ -586,7 +586,7 @@ impl GlobalState {
}
}
}
vfs::loader::Message::Progress { n_total, n_done, file, config_version } => {
vfs::loader::Message::Progress { n_total, n_done, dir, config_version } => {
always!(config_version <= self.vfs_config_version);
self.vfs_progress_config_version = config_version;
@ -603,12 +603,12 @@ impl GlobalState {
};
let mut message = format!("{n_done}/{n_total}");
if let Some(file) = file {
if let Some(dir) = dir {
message += &format!(
": {}",
match file.strip_prefix(&self.config.root_path()) {
match dir.strip_prefix(&self.config.root_path()) {
Some(relative_path) => relative_path.as_ref(),
None => file.as_ref(),
None => dir.as_ref(),
}
.display()
);

View file

@ -107,18 +107,12 @@ impl NotifyActor {
n_total,
n_done: 0,
config_version,
file: None,
dir: None,
});
self.watched_entries.clear();
for (i, entry) in config.load.into_iter().enumerate() {
self.send(loader::Message::Progress {
n_total,
n_done: i,
config_version,
file: None,
});
let watch = config.watch.contains(&i);
if watch {
self.watched_entries.push(entry.clone());
@ -127,7 +121,7 @@ impl NotifyActor {
self.load_entry(entry, watch, |file| loader::Message::Progress {
n_total,
n_done: i,
file: Some(file),
dir: Some(file),
config_version,
});
self.send(loader::Message::Loaded { files });
@ -135,7 +129,7 @@ impl NotifyActor {
n_total,
n_done: i + 1,
config_version,
file: None,
dir: None,
});
}
}

View file

@ -53,8 +53,8 @@ pub enum Message {
n_total: usize,
/// The files that have been loaded successfully.
n_done: usize,
/// The file being loaded, if any.
file: Option<AbsPathBuf>,
/// The dir being loaded, `None` if its for a file.
dir: Option<AbsPathBuf>,
/// The [`Config`] version.
config_version: u32,
},
@ -213,11 +213,11 @@ impl fmt::Debug for Message {
Message::Changed { files } => {
f.debug_struct("Changed").field("n_files", &files.len()).finish()
}
Message::Progress { n_total, n_done, file, config_version } => f
Message::Progress { n_total, n_done, dir, config_version } => f
.debug_struct("Progress")
.field("n_total", n_total)
.field("n_done", n_done)
.field("file", file)
.field("dir", dir)
.field("config_version", config_version)
.finish(),
}