-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove unused hints in pre build script * update whisper.cpp * misc * update whisper-rs * misc * fix pre build * feat: enable logs by default to file * feat: keep files for one day and clean older on startup
- Loading branch information
1 parent
cd05a7e
commit 8f8c8a2
Showing
19 changed files
with
181 additions
and
109 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use crate::utils::LogError; | ||
use crate::{cmd::get_logs_folder, config, logging::get_log_path}; | ||
use eyre::{eyre, ContextCompat, Result}; | ||
use vibe_core::get_vibe_temp_folder; | ||
|
||
pub fn clean_old_logs(app: &tauri::AppHandle) -> Result<()> { | ||
tracing::debug!("clean old logs"); | ||
let current_log_path = get_log_path(&app.clone())?; | ||
|
||
// Get logs folder | ||
let logs_folder = get_logs_folder(app.to_owned())?; | ||
let logs_folder = logs_folder.to_str().context("tostr")?; | ||
|
||
// Remove suffix | ||
let logs_folder = logs_folder.strip_suffix('/').unwrap_or(logs_folder); | ||
let logs_folder = logs_folder.strip_suffix('\\').unwrap_or(logs_folder); | ||
let pattern = format!( | ||
"{}/{}*{}", | ||
logs_folder, | ||
config::LOG_FILENAME_PREFIX, | ||
config::LOG_FILENAME_SUFFIX | ||
); | ||
tracing::debug!("searching old logs in {}", pattern); | ||
for path in glob::glob(&pattern)? { | ||
let path = path?; | ||
if path == current_log_path { | ||
tracing::debug!("Skip clean of current log path {}", path.display()); | ||
continue; | ||
} | ||
tracing::debug!("clean old log {}", path.display()); | ||
std::fs::remove_file(path)?; | ||
} | ||
Ok(()) | ||
} | ||
|
||
pub fn clean_old_files() -> Result<()> { | ||
let current_temp_dir = get_vibe_temp_folder(); | ||
let temp_dir = std::env::temp_dir(); | ||
let temp_dir = temp_dir.to_str().unwrap_or_default(); | ||
// Remove suffix | ||
let temp_dir = temp_dir.strip_suffix('/').unwrap_or(temp_dir); | ||
let temp_dir = temp_dir.strip_suffix('\\').unwrap_or(temp_dir); | ||
let pattern = format!("{}/vibe_temp*", temp_dir); | ||
tracing::debug!("searching old files in {}", pattern); | ||
for path in glob::glob(&pattern)? { | ||
let path = path?; | ||
if path == current_temp_dir { | ||
tracing::debug!("Skip deletion of {}", current_temp_dir.display()); | ||
continue; | ||
} | ||
tracing::debug!("Clean old folder {}", path.clone().display()); | ||
std::fs::remove_dir_all(path.clone()) | ||
.map_err(|e| eyre!("failed to delete {}: {:?}", path.display(), e)) | ||
.log_error(); | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.