From db2c23ea0e3eb0fbc4579a1024b3c6220c9f9a4c Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 15 Aug 2023 14:09:00 +0200 Subject: Name backup directories after current epoch --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') 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::(); -- cgit v1.2.3