5035: Less error-prone naming r=matklad a=matklad



bors r+
🤖

5037: Don't watch dirs if not asked to r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-06-24 15:18:13 +00:00 committed by GitHub
commit 7e61f4c59e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 22 deletions

View file

@ -67,8 +67,8 @@ pub(crate) fn load(
// wait until Vfs has loaded all roots // wait until Vfs has loaded all roots
for task in receiver { for task in receiver {
match task { match task {
vfs::loader::Message::Progress { n_entries_done, n_entries_total } => { vfs::loader::Message::Progress { n_done, n_total } => {
if n_entries_done == n_entries_total { if n_done == n_total {
break; break;
} }
} }

View file

@ -305,18 +305,12 @@ fn loop_turn(
} }
} }
} }
vfs::loader::Message::Progress { n_entries_total, n_entries_done } => { vfs::loader::Message::Progress { n_total, n_done } => {
if n_entries_done == n_entries_done { if n_done == n_total {
loop_state.status = Status::Ready; loop_state.status = Status::Ready;
became_ready = true; became_ready = true;
} }
report_progress( report_progress(loop_state, &connection.sender, n_done, n_total, "roots scanned")
loop_state,
&connection.sender,
n_entries_done,
n_entries_total,
"roots scanned",
)
} }
}, },
Event::CheckWatcher(task) => on_check_task(task, global_state, task_sender)?, Event::CheckWatcher(task) => on_check_task(task, global_state, task_sender)?,

View file

@ -89,8 +89,8 @@ impl LoaderActor {
match event { match event {
Event::Message(msg) => match msg { Event::Message(msg) => match msg {
Message::Config(config) => { Message::Config(config) => {
let n_entries_total = config.load.len(); let n_total = config.load.len();
self.send(loader::Message::Progress { n_entries_total, n_entries_done: 0 }); self.send(loader::Message::Progress { n_total, n_done: 0 });
self.unwatch_all(); self.unwatch_all();
self.config.clear(); self.config.clear();
@ -99,10 +99,7 @@ impl LoaderActor {
let watch = config.watch.contains(&i); let watch = config.watch.contains(&i);
let files = self.load_entry(entry, watch); let files = self.load_entry(entry, watch);
self.send(loader::Message::Loaded { files }); self.send(loader::Message::Loaded { files });
self.send(loader::Message::Progress { self.send(loader::Message::Progress { n_total, n_done: i + 1 });
n_entries_total,
n_entries_done: i + 1,
});
} }
self.config.sort_by(|x, y| x.0.cmp(&y.0)); self.config.sort_by(|x, y| x.0.cmp(&y.0));
} }
@ -199,7 +196,7 @@ impl LoaderActor {
let is_dir = entry.file_type().is_dir(); let is_dir = entry.file_type().is_dir();
let is_file = entry.file_type().is_file(); let is_file = entry.file_type().is_file();
let abs_path = AbsPathBuf::try_from(entry.into_path()).unwrap(); let abs_path = AbsPathBuf::try_from(entry.into_path()).unwrap();
if is_dir { if is_dir && watch {
self.watch(abs_path.clone()); self.watch(abs_path.clone());
} }
let rel_path = abs_path.strip_prefix(&path)?; let rel_path = abs_path.strip_prefix(&path)?;

View file

@ -16,7 +16,7 @@ pub struct Config {
} }
pub enum Message { pub enum Message {
Progress { n_entries_total: usize, n_entries_done: usize }, Progress { n_total: usize, n_done: usize },
Loaded { files: Vec<(AbsPathBuf, Option<Vec<u8>>)> }, Loaded { files: Vec<(AbsPathBuf, Option<Vec<u8>>)> },
} }
@ -56,10 +56,10 @@ impl fmt::Debug for Message {
Message::Loaded { files } => { Message::Loaded { files } => {
f.debug_struct("Loaded").field("n_files", &files.len()).finish() f.debug_struct("Loaded").field("n_files", &files.len()).finish()
} }
Message::Progress { n_entries_total, n_entries_done } => f Message::Progress { n_total, n_done } => f
.debug_struct("Progress") .debug_struct("Progress")
.field("n_entries_total", n_entries_total) .field("n_total", n_total)
.field("n_entries_done", n_entries_done) .field("n_done", n_done)
.finish(), .finish(),
} }
} }