File tree Expand file tree Collapse file tree 6 files changed +20
-4
lines changed
common/tedge_config/src/tedge_config_cli Expand file tree Collapse file tree 6 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ pub enum TEdgeConfigError {
26
26
27
27
#[ error( transparent) ]
28
28
Multi ( #[ from] Multi ) ,
29
+
30
+ #[ error( transparent) ]
31
+ DirNotFound ( #[ from] tedge_utils:: paths:: PathsError ) ,
29
32
}
30
33
31
34
impl TEdgeConfigError {
Original file line number Diff line number Diff line change 1
1
use c8y_api:: smartrest:: topic:: C8yTopic ;
2
+ use tedge_utils:: paths:: validate_parent_dir_exists;
2
3
3
4
use std:: path:: Path ;
4
5
use std:: path:: PathBuf ;
@@ -86,7 +87,7 @@ impl ConfigManagerConfig {
86
87
let tedge_http_address = tedge_config. query ( HttpBindAddressSetting ) ?;
87
88
let tedge_http_port: u16 = tedge_config. query ( HttpPortSetting ) ?. into ( ) ;
88
89
89
- Ok ( ConfigManagerConfig :: new (
90
+ let config = ConfigManagerConfig :: new (
90
91
config_dir,
91
92
tmp_dir,
92
93
data_dir,
@@ -95,6 +96,8 @@ impl ConfigManagerConfig {
95
96
mqtt_port,
96
97
tedge_http_address,
97
98
tedge_http_port,
98
- ) )
99
+ ) ;
100
+ validate_parent_dir_exists ( config. plugin_config_path . as_path ( ) ) ?;
101
+ Ok ( config)
99
102
}
100
103
}
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ use tedge_config::TEdgeConfig;
18
18
use tedge_config:: TEdgeConfigError ;
19
19
use tedge_config:: TmpPathSetting ;
20
20
use tedge_mqtt_ext:: MqttMessage ;
21
+ use tedge_utils:: paths:: validate_parent_dir_exists;
21
22
22
23
pub const DEFAULT_PLUGIN_CONFIG_FILE_NAME : & str = "c8y-log-plugin.toml" ;
23
24
pub const DEFAULT_OPERATION_DIR_NAME : & str = "c8y/" ;
@@ -54,6 +55,7 @@ impl LogManagerConfig {
54
55
let plugin_config_path = config_dir
55
56
. join ( DEFAULT_OPERATION_DIR_NAME )
56
57
. join ( DEFAULT_PLUGIN_CONFIG_FILE_NAME ) ;
58
+ validate_parent_dir_exists ( & plugin_config_path) ?;
57
59
58
60
let plugin_config = LogPluginConfig :: new ( & plugin_config_path) ;
59
61
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ repository = { workspace = true }
11
11
12
12
[dependencies ]
13
13
async-trait = " 0.1"
14
+ log = " 0.4"
14
15
tedge_actors = { path = " ../../core/tedge_actors" }
15
16
tedge_utils = { path = " ../../common/tedge_utils" , features = [" fs-notify" ] }
16
17
tokio = { version = " 1.23" , features = [" macros" ] }
Original file line number Diff line number Diff line change 1
1
use async_trait:: async_trait;
2
+ use log:: error;
2
3
use std:: path:: PathBuf ;
3
4
use tedge_actors:: futures:: channel:: mpsc;
4
5
use tedge_actors:: futures:: StreamExt ;
@@ -121,9 +122,14 @@ impl Actor for FsWatchActor {
121
122
}
122
123
123
124
async fn run ( & mut self ) -> Result < ( ) , RuntimeError > {
124
- let mut fs_notify = NotifyStream :: try_default ( ) . unwrap ( ) ;
125
+ let mut fs_notify = NotifyStream :: try_default ( ) . map_err ( Box :: new ) ? ;
125
126
for ( watch_path, _) in self . messages . get_watch_dirs ( ) . iter ( ) {
126
- fs_notify. add_watcher ( watch_path) . unwrap ( ) ;
127
+ if let Err ( err) = fs_notify. add_watcher ( watch_path) {
128
+ error ! (
129
+ "Failed to add file watcher to the {} due to: {err}" ,
130
+ watch_path. display( )
131
+ ) ;
132
+ }
127
133
}
128
134
129
135
loop {
You can’t perform that action at this time.
0 commit comments