feat: 收口 Rust Web 3000 主链
This commit is contained in:
@@ -49,11 +49,7 @@ impl LocalFolderWatcherRegistry {
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn active_watcher_count(&self) -> usize {
|
||||
self.inner
|
||||
.entries
|
||||
.lock()
|
||||
.expect("registry lock")
|
||||
.len()
|
||||
self.inner.entries.lock().expect("registry lock").len()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +63,13 @@ impl LocalFolderWatcherRegistryInner {
|
||||
key: &str,
|
||||
canonical_root: &Path,
|
||||
) -> Result<Arc<LocalFolderWatchChannel>, String> {
|
||||
if let Some(existing) = self.entries.lock().expect("registry lock").get(key).cloned() {
|
||||
if let Some(existing) = self
|
||||
.entries
|
||||
.lock()
|
||||
.expect("registry lock")
|
||||
.get(key)
|
||||
.cloned()
|
||||
{
|
||||
return Ok(existing);
|
||||
}
|
||||
|
||||
@@ -107,10 +109,7 @@ struct LocalFolderWatchChannel {
|
||||
}
|
||||
|
||||
impl LocalFolderWatchChannel {
|
||||
fn new(
|
||||
_root_uri: String,
|
||||
parts: (broadcast::Sender<Value>, oneshot::Sender<()>),
|
||||
) -> Self {
|
||||
fn new(_root_uri: String, parts: (broadcast::Sender<Value>, oneshot::Sender<()>)) -> Self {
|
||||
Self {
|
||||
sender: parts.0,
|
||||
subscriber_count: AtomicUsize::new(0),
|
||||
@@ -321,7 +320,9 @@ mod tests {
|
||||
let first_root = test_root("first");
|
||||
let second_root = test_root("second");
|
||||
|
||||
let first = registry.subscribe(&first_root).expect("first root subscription");
|
||||
let first = registry
|
||||
.subscribe(&first_root)
|
||||
.expect("first root subscription");
|
||||
let second = registry
|
||||
.subscribe(&second_root)
|
||||
.expect("second root subscription");
|
||||
@@ -340,9 +341,11 @@ mod tests {
|
||||
#[test]
|
||||
fn event_kind_filter_ignores_access_events() {
|
||||
assert!(should_emit_event_kind(&EventKind::Create(CreateKind::File)));
|
||||
assert!(should_emit_event_kind(&EventKind::Modify(ModifyKind::Data(
|
||||
DataChange::Content,
|
||||
))));
|
||||
assert!(!should_emit_event_kind(&EventKind::Access(AccessKind::Read)));
|
||||
assert!(should_emit_event_kind(&EventKind::Modify(
|
||||
ModifyKind::Data(DataChange::Content,)
|
||||
)));
|
||||
assert!(!should_emit_event_kind(&EventKind::Access(
|
||||
AccessKind::Read
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user