This commit is contained in:
Antonio Scandurra 2021-04-16 17:22:30 +02:00
parent b68b0fce56
commit ce5fbbb46b

View file

@ -428,16 +428,16 @@ impl BackgroundScanner {
} }
fn run(&self) { fn run(&self) {
let scanner = self.clone();
let event_stream = fsevent::EventStream::new( let event_stream = fsevent::EventStream::new(
&[self.path.as_ref()], &[self.path.as_ref()],
Duration::from_millis(100), Duration::from_millis(100),
|events| { |events| {
if let Err(err) = scanner.process_events(events) { match self.process_events(events) {
// TODO: handle errors Ok(alive) => alive,
false Err(err) => {
} else { // TODO: handle errors
true false
}
} }
}, },
); );
@ -954,7 +954,7 @@ mod tests {
let tree = app.add_model(|ctx| Worktree::new(dir.path(), ctx)); let tree = app.add_model(|ctx| Worktree::new(dir.path(), ctx));
assert_condition(1, 300, || app.read(|ctx| tree.read(ctx).file_count() == 1)).await; assert_condition(1, 300, || app.read(|ctx| tree.read(ctx).file_count() == 1)).await;
let file_entry = app.read(|ctx| { let file_inode = app.read(|ctx| {
tree.read(ctx) tree.read(ctx)
.snapshot() .snapshot()
.inode_for_path("dir1/file") .inode_for_path("dir1/file")
@ -963,7 +963,7 @@ mod tests {
app.read(|ctx| { app.read(|ctx| {
let tree = tree.read(ctx); let tree = tree.read(ctx);
assert_eq!( assert_eq!(
tree.path_for_inode(file_entry, false) tree.path_for_inode(file_inode, false)
.unwrap() .unwrap()
.to_str() .to_str()
.unwrap(), .unwrap(),
@ -975,14 +975,21 @@ mod tests {
assert_condition(1, 300, || { assert_condition(1, 300, || {
app.read(|ctx| { app.read(|ctx| {
let tree = tree.read(ctx); let tree = tree.read(ctx);
tree.path_for_inode(file_entry, false) tree.path_for_inode(file_inode, false)
.unwrap() .unwrap()
.to_str() .to_str()
.unwrap() .unwrap()
== "dir2/file" == "dir2/file"
}) })
}) })
.await .await;
app.read(|ctx| {
let tree = tree.read(ctx);
assert_eq!(
tree.snapshot().inode_for_path("dir2/file"),
Some(file_inode)
);
});
}); });
} }
} }