Skip to content

Commit

Permalink
Use EPOCH as fallback instead of now()
Browse files Browse the repository at this point in the history
  • Loading branch information
CoreyShupe committed May 6, 2024
1 parent 2564912 commit 02a3f5e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions theseus/src/api/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ pub async fn get_logs_from_type(
clear_contents: Option<bool>,
logs: &mut Vec<crate::Result<Logs>>,
) -> crate::Result<()> {
let now = SystemTime::now();

let logs_folder = match log_type {
LogType::InfoLog => {
DirectoryInfo::profile_logs_dir(profile_path).await?
Expand All @@ -116,7 +114,7 @@ pub async fn get_logs_from_type(
{
let entry: std::fs::DirEntry =
entry.map_err(|e| IOError::with_path(e, &logs_folder))?;
let age = entry.metadata()?.created().unwrap_or_else(|_| *now);
let age = entry.metadata()?.created().unwrap_or_else(|_| SystemTime::UNIX_EPOCH);
let path = entry.path();
if !path.is_file() {
continue;
Expand Down Expand Up @@ -186,7 +184,7 @@ pub async fn get_logs_by_filename(
.join(&filename);

let metadata = std::fs::metadata(&path)?;
let age = metadata.created().unwrap_or_else(|_| SystemTime::now());
let age = metadata.created().unwrap_or_else(|_| SystemTime::UNIX_EPOCH);

Logs::build(log_type, age, &profile_path, filename, Some(true)).await
}
Expand Down

0 comments on commit 02a3f5e

Please sign in to comment.