mirror of
https://github.com/sreedevk/deduplicator.git
synced 2026-09-05 06:50:44 +00:00
implemented deduplicator with file identifiers
This commit is contained in:
@@ -6,9 +6,9 @@ use anyhow::Result;
|
||||
use glob::glob;
|
||||
use std::{fs, io};
|
||||
|
||||
pub fn duplicates(app_opts: App) -> Result<Vec<File>> {
|
||||
index_files(scan(app_opts)?);
|
||||
database::duplicate_hashes()
|
||||
pub fn duplicates(app_opts: App, connection: &sqlite::Connection) -> Result<Vec<File>> {
|
||||
index_files(scan(app_opts)?, connection);
|
||||
database::duplicate_hashes(connection)
|
||||
}
|
||||
|
||||
fn scan(app_opts: App) -> Result<Vec<String>> {
|
||||
@@ -46,7 +46,7 @@ fn scan(app_opts: App) -> Result<Vec<String>> {
|
||||
Ok(files)
|
||||
}
|
||||
|
||||
fn index_files(files: Vec<String>) {
|
||||
fn index_files(files: Vec<String>, connection: &sqlite::Connection) {
|
||||
files
|
||||
.into_iter()
|
||||
.map(|file| {
|
||||
@@ -54,7 +54,7 @@ fn index_files(files: Vec<String>) {
|
||||
database::File { path: file, hash }
|
||||
})
|
||||
.for_each(|file| {
|
||||
database::put(file).unwrap();
|
||||
database::put(&file, connection).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user