Эх сурвалжийг харах

hosts: modify last_seen instead of entire entry on store_or_update()

draoi 2 жил өмнө
parent
commit
0958e69b62
1 өөрчлөгдсөн 2 нэмэгдсэн , 2 устгасан
  1. 2 2
      src/net/hosts.rs

+ 2 - 2
src/net/hosts.rs

@@ -351,8 +351,8 @@ impl HostContainer {
         trace!(target: "net::hosts::store_or_update()", "[START]");
         let color_code = color.clone() as usize;
         let mut list = self.hostlists[color_code].write().await;
-        if let Some(position) = list.iter().position(|(u, _)| u == &addr) {
-            list[position] = (addr.clone(), last_seen);
+        if let Some(entry) = list.iter_mut().find(|(u, _)| *u == addr) {
+            entry.1 = last_seen;
             debug!(target: "net::hosts::store_or_update()", "Updated [{}] entry on {:?} list",
                 addr, color.clone());
         } else {