filetype requirement removed

This commit is contained in:
sreedev
2022-12-27 21:19:13 -05:00
parent f8242ca4ac
commit 4c9f848140
4 changed files with 79 additions and 2 deletions

View File

@@ -9,7 +9,6 @@ use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
let connection = sqlite::open(":memory:")?;
database::setup(&connection)?;
let duplicates = scanner::duplicates(cli::App::parse(), &connection)?;

View File

@@ -5,6 +5,7 @@ use crate::database;
use anyhow::Result;
use glob::glob;
use std::fs;
use rayon::prelude::*;
pub fn duplicates(app_opts: App, connection: &sqlite::Connection) -> Result<Vec<File>> {
index_files(scan(app_opts)?, connection);
@@ -33,12 +34,13 @@ fn scan(app_opts: App) -> Result<Vec<String>> {
.collect();
let files: Vec<String> = glob_patterns
.into_iter()
.into_par_iter()
.map(|glob_pattern| glob(&glob_pattern.as_os_str().to_str().unwrap()))
.map(|glob_result| glob_result.unwrap())
.flat_map(|file_vec| {
file_vec
.map(|x| x.unwrap().as_os_str().to_str().unwrap().to_string())
.filter(|glob_result| fs::metadata(glob_result).unwrap().is_file() )
.collect::<Vec<String>>()
})
.collect();