Diff two snapshots to produce a `TurnChanges`.
(before: &FileSnapshot, after: &FileSnapshot)
| 123 | |
| 124 | /// Diff two snapshots to produce a `TurnChanges`. |
| 125 | fn diff_snapshots(before: &FileSnapshot, after: &FileSnapshot) -> TurnChanges { |
| 126 | let mut modified = Vec::new(); |
| 127 | let mut added = Vec::new(); |
| 128 | let mut deleted = Vec::new(); |
| 129 | |
| 130 | // Find modified and deleted files |
| 131 | for (path, before_entry) in before { |
| 132 | match after.get(path) { |
| 133 | Some(after_entry) => { |
| 134 | // File exists in both — check if changed |
| 135 | if before_entry.mtime != after_entry.mtime || before_entry.size != after_entry.size |
| 136 | { |
| 137 | modified.push(path.clone()); |
| 138 | } |
| 139 | } |
| 140 | None => { |
| 141 | // File was in before but not after — deleted |
| 142 | deleted.push(path.clone()); |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | // Find added files |
| 148 | for path in after.keys() { |
| 149 | if !before.contains_key(path) { |
| 150 | added.push(path.clone()); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | // Sort for deterministic output |
| 155 | modified.sort(); |
| 156 | added.sort(); |
| 157 | deleted.sort(); |
| 158 | |
| 159 | TurnChanges::new() |
| 160 | .with_modified(modified) |
| 161 | .with_added(added) |
| 162 | .with_deleted(deleted) |
| 163 | } |
| 164 | |
| 165 | // FallbackWatcher |
| 166 |