From ed46964df74ff592f39295fe20d083b144089310 Mon Sep 17 00:00:00 2001
From: chenjiayi <chenjiayi22@huawei.com>
Date: Tue, 14 Nov 2023 17:14:36 +0800
Subject: [PATCH 059/103] fix(device): drop unnecessary error throwing out

In some device methods, the device object should prepare inner data by reading
database, but it tolerates failure.
---
 libs/device/src/device.rs | 43 +++++++++++++--------------------------
 1 file changed, 14 insertions(+), 29 deletions(-)

diff --git a/libs/device/src/device.rs b/libs/device/src/device.rs
index 3845e21c..6a43be82 100644
--- a/libs/device/src/device.rs
+++ b/libs/device/src/device.rs
@@ -955,14 +955,14 @@ impl Device {
 
     /// check whether the device has the tag
     pub fn has_tag(&self, tag: &str) -> Result<bool, Error> {
-        self.read_db()?;
+        let _ = self.read_db();
 
         Ok(self.all_tags.borrow().contains(tag))
     }
 
     /// check whether the device has the current tag
     pub fn has_current_tag(&self, tag: &str) -> Result<bool, Error> {
-        self.read_db()?;
+        let _ = self.read_db();
 
         Ok(self.current_tags.borrow().contains(tag))
     }
@@ -2751,48 +2751,33 @@ impl<'a, 'b: 'a, K: 'a, V: 'a> IntoIterator for &'b HashMapRefWrapper<'a, K, V>
 }
 
 impl Device {
-    /// return the tag iterator
+    /// Return the tag iterator.
+    ///
+    /// The device object will try to load tags from db firstly.
     pub fn tag_iter(&self) -> HashSetRefWrapper<String> {
-        if let Err(e) = self.read_db() {
-            log::debug!(
-                "failed to read db of '{}': {}",
-                self.get_device_id()
-                    .unwrap_or_else(|_| self.devpath.borrow().clone()),
-                e
-            )
-        }
+        let _ = self.read_db();
 
         HashSetRefWrapper {
             r: self.all_tags.borrow(),
         }
     }
 
-    /// return the current tag iterator
+    /// Return the current tag iterator.
+    ///
+    /// The device object will try to load tags from db firstly.
     pub fn current_tag_iter(&self) -> HashSetRefWrapper<String> {
-        if let Err(e) = self.read_db() {
-            log::error!(
-                "failed to read db of '{}': {}",
-                self.get_device_id()
-                    .unwrap_or_else(|_| self.devpath.borrow().clone()),
-                e
-            )
-        }
+        let _ = self.read_db();
 
         HashSetRefWrapper {
             r: self.current_tags.borrow(),
         }
     }
 
-    /// return the tag iterator
+    /// Return the devlink iterator
+    /// 
+    /// The device object will try to load devlinks from db firstly.
     pub fn devlink_iter(&self) -> HashSetRefWrapper<String> {
-        if let Err(e) = self.read_db() {
-            log::debug!(
-                "failed to read db of '{}': {}",
-                self.get_device_id()
-                    .unwrap_or_else(|_| self.devpath.borrow().clone()),
-                e
-            )
-        }
+        let _ = self.read_db();
 
         HashSetRefWrapper {
             r: self.devlinks.borrow(),
-- 
2.33.0

