diff options
Diffstat (limited to 'src/pathinfo.rs')
-rw-r--r-- | src/pathinfo.rs | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/pathinfo.rs b/src/pathinfo.rs index 3e4b5c2..212dd2a 100644 --- a/src/pathinfo.rs +++ b/src/pathinfo.rs | |||
@@ -15,11 +15,11 @@ use crate::{ | |||
15 | 15 | ||
16 | #[derive(Debug, Clone, Serialize, Deserialize)] | 16 | #[derive(Debug, Clone, Serialize, Deserialize)] |
17 | pub struct PathInfo { | 17 | pub struct PathInfo { |
18 | pub is_file: bool, | 18 | is_file: bool, |
19 | rel_location: String, | 19 | rel_location: String, |
20 | location_root: LocationRoot, | 20 | location_root: LocationRoot, |
21 | last_modified: Option<BackupId>, | 21 | last_modified: Option<BackupId>, |
22 | pub children: Vec<PathInfo>, | 22 | children: Vec<PathInfo>, |
23 | } | 23 | } |
24 | 24 | ||
25 | impl PathInfo { | 25 | impl PathInfo { |
@@ -37,7 +37,9 @@ impl PathInfo { | |||
37 | println!("Handling {rel_location}"); | 37 | println!("Handling {rel_location}"); |
38 | let path = Self::get_abs_path(&location_root.to_string(), rel_location); | 38 | let path = Self::get_abs_path(&location_root.to_string(), rel_location); |
39 | Ok(if path.is_dir() { | 39 | Ok(if path.is_dir() { |
40 | let mut last_modified = None; | 40 | let mut last_modified = Some(String::new()); |
41 | let mut last_modified_timestamp = 0; | ||
42 | |||
41 | let mut children: Vec<PathInfo> = Vec::new(); | 43 | let mut children: Vec<PathInfo> = Vec::new(); |
42 | 44 | ||
43 | let paths = std::fs::read_dir(path).unwrap(); | 45 | let paths = std::fs::read_dir(path).unwrap(); |
@@ -48,11 +50,17 @@ impl PathInfo { | |||
48 | panic!("HUH"); | 50 | panic!("HUH"); |
49 | }; | 51 | }; |
50 | let handle = Self::handle_dir(config, rl.1, location_root)?; | 52 | let handle = Self::handle_dir(config, rl.1, location_root)?; |
51 | if handle.last_modified.is_some() { | 53 | if let Some(lm) = handle.last_modified.clone() { |
52 | // FIX: Check if new last modified is newer than old one | 54 | if last_modified != None { |
53 | last_modified = handle.last_modified.clone(); | 55 | let ts = Backup::from_index(config, &lm)?.timestamp; |
56 | if ts > last_modified_timestamp { | ||
57 | last_modified_timestamp = ts; | ||
58 | last_modified = Some(lm); | ||
59 | }; | ||
60 | } | ||
61 | } else { | ||
62 | last_modified = None; | ||
54 | }; | 63 | }; |
55 | last_modified = None; | ||
56 | children.push(handle); | 64 | children.push(handle); |
57 | } | 65 | } |
58 | Self { | 66 | Self { |
@@ -103,7 +111,7 @@ impl PathInfo { | |||
103 | return Ok(None); | 111 | return Ok(None); |
104 | }; | 112 | }; |
105 | 113 | ||
106 | let modified_backup = if let Some(modified_backup_id) = last_file.last_modified.clone() { | 114 | let modified_backup = if let Some(modified_backup_id) = &last_file.last_modified { |
107 | Backup::from_index(config, modified_backup_id)? | 115 | Backup::from_index(config, modified_backup_id)? |
108 | } else { | 116 | } else { |
109 | last_backup | 117 | last_backup |