mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-21 11:26:15 +02:00
fix(log): propagte some errors and avoid unwrapping (#1297)
This commit is contained in:
+11
-12
@@ -434,7 +434,7 @@ impl Builder {
|
||||
TargetKind::Stderr => std::io::stderr().into(),
|
||||
TargetKind::Folder { path, file_name } => {
|
||||
if !path.exists() {
|
||||
fs::create_dir_all(&path).unwrap();
|
||||
fs::create_dir_all(&path)?;
|
||||
}
|
||||
|
||||
fern::log_file(get_log_file_path(
|
||||
@@ -450,9 +450,9 @@ impl Builder {
|
||||
TargetKind::LogDir { .. } => continue,
|
||||
#[cfg(desktop)]
|
||||
TargetKind::LogDir { file_name } => {
|
||||
let path = app_handle.path().app_log_dir().unwrap();
|
||||
let path = app_handle.path().app_log_dir()?;
|
||||
if !path.exists() {
|
||||
fs::create_dir_all(&path).unwrap();
|
||||
fs::create_dir_all(&path)?;
|
||||
}
|
||||
|
||||
fern::log_file(get_log_file_path(
|
||||
@@ -474,7 +474,7 @@ impl Builder {
|
||||
};
|
||||
let app_handle = app_handle.clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
app_handle.emit("log://log", payload).unwrap();
|
||||
let _ = app_handle.emit("log://log", payload);
|
||||
});
|
||||
})
|
||||
}
|
||||
@@ -511,13 +511,9 @@ fn get_log_file_path(
|
||||
file_name,
|
||||
timezone_strategy
|
||||
.get_now()
|
||||
.format(
|
||||
&time::format_description::parse(
|
||||
"[year]-[month]-[day]_[hour]-[minute]-[second]"
|
||||
)
|
||||
.unwrap()
|
||||
)
|
||||
.unwrap(),
|
||||
.format(&time::format_description::parse(
|
||||
"[year]-[month]-[day]_[hour]-[minute]-[second]"
|
||||
)?)?,
|
||||
));
|
||||
if to.is_file() {
|
||||
// designated rotated log file name already exists
|
||||
@@ -525,7 +521,10 @@ fn get_log_file_path(
|
||||
let mut to_bak = to.clone();
|
||||
to_bak.set_file_name(format!(
|
||||
"{}.bak",
|
||||
to_bak.file_name().unwrap().to_string_lossy()
|
||||
to_bak
|
||||
.file_name()
|
||||
.map(|f| f.to_string_lossy())
|
||||
.unwrap_or_default()
|
||||
));
|
||||
fs::rename(&to, to_bak)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user