From 3b4378dfed00e22d684056f737c0966fcdad0400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sat, 1 Oct 2022 22:16:59 +0200 Subject: [PATCH] fix: actually remove objects on rescan --- src/database/stores/fs/db.rs | 6 ++++++ src/database/stores/fs/mod.rs | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/database/stores/fs/db.rs b/src/database/stores/fs/db.rs index 1447092..b640e68 100644 --- a/src/database/stores/fs/db.rs +++ b/src/database/stores/fs/db.rs @@ -49,3 +49,9 @@ pub struct NewFile { pub size: i64, pub mtime: Option, } + +impl From for crate::addressing::Address { + fn from(file: File) -> Self { + crate::addressing::Address::Hash(file.hash) + } +} diff --git a/src/database/stores/fs/mod.rs b/src/database/stores/fs/mod.rs index a6d77df..aca279f 100644 --- a/src/database/stores/fs/mod.rs +++ b/src/database/stores/fs/mod.rs @@ -18,7 +18,7 @@ use chrono::prelude::*; use diesel::r2d2::{self, ConnectionManager}; use diesel::ExpressionMethods; use diesel::{Connection, QueryDsl, RunQueryDsl, SqliteConnection}; -use log::{debug, error, info, warn, trace}; +use log::{debug, error, info, trace, warn}; use lru::LruCache; use rayon::prelude::*; use serde_json::json; @@ -216,7 +216,7 @@ impl FsStore { let cleanup_results = existing_files.iter().filter(|f| f.valid).map(|file| { let trans_result = upconnection.transaction::<_, Error, _>(|| { self.file_set_valid(file.id, false)?; - // remove_object(&connection, )? + upconnection.remove_object(Address::from(file.clone()))?; Ok(()) }); @@ -682,7 +682,11 @@ impl UpStore for FsStore { mut job_container: JobContainer, initial: bool, ) -> Result, StoreError> { - trace!("Running a vault update of {:?}, initial = {}.", self.path, initial); + trace!( + "Running a vault update of {:?}, initial = {}.", + self.path, + initial + ); let job_result = job_container.add_job("REIMPORT", "Scaning vault directory..."); match job_result {