38 lines
1.2 KiB
Diff
38 lines
1.2 KiB
Diff
From 3081211857ad265f3c7d1365cc558093ece19586 Mon Sep 17 00:00:00 2001
|
|
From: chenjiayi <chenjiayi22@huawei.com>
|
|
Date: Tue, 15 Aug 2023 10:14:43 +0800
|
|
Subject: [PATCH 2/3] fix(device): avoid inserting empty tag
|
|
|
|
If a tag is empty, the device id file will be directly created under
|
|
/run/devmaster/tags, which is not expected.
|
|
---
|
|
libs/device/src/device.rs | 10 ++++++++--
|
|
1 file changed, 8 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/libs/device/src/device.rs b/libs/device/src/device.rs
|
|
index 36607bcb..bf67fce9 100644
|
|
--- a/libs/device/src/device.rs
|
|
+++ b/libs/device/src/device.rs
|
|
@@ -1325,10 +1325,16 @@ impl Device {
|
|
|
|
/// add tag to the device object
|
|
pub fn add_tag(&self, tag: &str, both: bool) -> Result<(), Error> {
|
|
- self.all_tags.borrow_mut().insert(tag.to_string());
|
|
+ if tag.trim().is_empty() {
|
|
+ return Ok(());
|
|
+ }
|
|
+
|
|
+ self.all_tags.borrow_mut().insert(tag.trim().to_string());
|
|
|
|
if both {
|
|
- self.current_tags.borrow_mut().insert(tag.to_string());
|
|
+ self.current_tags
|
|
+ .borrow_mut()
|
|
+ .insert(tag.trim().to_string());
|
|
}
|
|
self.property_tags_outdated.replace(true);
|
|
Ok(())
|
|
--
|
|
2.33.0
|
|
|