Find files that are in the database but no longer exist on disk.
(db: &Database, current_files: &[String])
| 129 | |
| 130 | /// Find files that are in the database but no longer exist on disk. |
| 131 | pub async fn find_removed_files(db: &Database, current_files: &[String]) -> Result<Vec<String>> { |
| 132 | let all_db_files = db.get_all_files().await?; |
| 133 | let current_set: std::collections::HashSet<&str> = current_files |
| 134 | .iter() |
| 135 | .map(std::string::String::as_str) |
| 136 | .collect(); |
| 137 | let mut removed = Vec::new(); |
| 138 | for file_record in &all_db_files { |
| 139 | if !current_set.contains(file_record.path.as_str()) { |
| 140 | removed.push(file_record.path.clone()); |
| 141 | } |
| 142 | } |
| 143 | Ok(removed) |
| 144 | } |