aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-08-15 14:09:00 +0200
committerThomas Voss <mail@thomasvoss.com> 2023-08-15 14:09:00 +0200
commitdb2c23ea0e3eb0fbc4579a1024b3c6220c9f9a4c (patch)
tree7e0e05d0967de0efd1248e49591fa75bca071499 /src
parent3890e45009178b0172b9622a3acbc1bf5280f386 (diff)
Name backup directories after current epoch
Diffstat (limited to 'src')
-rw-r--r--src/main.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index def98c2..bf7c142 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,6 +9,7 @@ use std::{
iter,
path::{Component, Display, Path, PathBuf},
process::{self, Command, Stdio},
+ time::{SystemTime, UNIX_EPOCH},
};
use itertools::Itertools;
@@ -151,14 +152,16 @@ fn work() -> Result<(), io::Error> {
let mut cache_dir = PathBuf::default();
if flags.backup {
- let pid = process::id().to_string();
+ let ts = require!(SystemTime::now().duration_since(UNIX_EPOCH))
+ .as_secs()
+ .to_string();
let cache_base = env::var("XDG_CACHE_HOME").unwrap_or_else(|_| {
err!("XDG_CACHE_HOME variable must be set");
});
cache_dir = [
Path::new(cache_base.as_str()),
Path::new("mmv"),
- Path::new(pid.as_str()),
+ Path::new(ts.as_str()),
]
.iter()
.collect::<PathBuf>();