Skip to content

Commit 4b843e7

Browse files
committed
Add timestamp suffix for capture files
1 parent 75fba8b commit 4b843e7

File tree

4 files changed

+209
-2
lines changed

4 files changed

+209
-2
lines changed

Cargo.lock

Lines changed: 202 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

oryx-tui/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ env_logger = "0.11"
2929
serde_json = "1"
3030
serde = { version = "1", features = ["derive"] }
3131
regex = "1"
32+
chrono = "0.4"
3233

3334
[[bin]]
3435
name = "oryx"

oryx-tui/src/export.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use std::{
44
os::unix::fs::chown,
55
};
66

7+
use chrono::Local;
8+
79
use crate::{
810
app::AppResult,
911
packet::{
@@ -15,14 +17,16 @@ use crate::{
1517
pub fn export(packets: &[AppPacket]) -> AppResult<()> {
1618
let uid = unsafe { libc::geteuid() };
1719

20+
let local_date = Local::now().format("%Y-%m-%d_%Hh%M");
21+
1822
let oryx_export_dir = dirs::home_dir().unwrap().join("oryx");
1923

2024
if !oryx_export_dir.exists() {
2125
create_dir(&oryx_export_dir)?;
2226
chown(&oryx_export_dir, Some(uid), Some(uid))?;
2327
}
2428

25-
let oryx_export_file = oryx_export_dir.join("capture");
29+
let oryx_export_file = oryx_export_dir.join(format!("capture-{local_date}"));
2630

2731
let mut file = OpenOptions::new()
2832
.create(true)

oryx-tui/src/section/inspection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl Inspection {
146146
match export::export(&app_packets) {
147147
Ok(_) => {
148148
Notification::send(
149-
"Packets exported to ~/oryx/capture file".to_string(),
149+
"Packets exported to ~/oryx directory".to_string(),
150150
NotificationLevel::Info,
151151
event_sender,
152152
)?;

0 commit comments

Comments
 (0)