improve fs rescan logging
parent
4b1a8c862c
commit
4233a5da46
|
@ -19,7 +19,7 @@ use crate::util::jobs::{Job, JobContainer, JobId, State};
|
|||
use anyhow::{Error, Result};
|
||||
use chrono::prelude::*;
|
||||
use diesel::Connection;
|
||||
use log::{error, info, warn};
|
||||
use log::{debug, error, info, warn};
|
||||
use lru::LruCache;
|
||||
use rayon::prelude::*;
|
||||
use serde_json::Value;
|
||||
|
@ -93,14 +93,18 @@ fn _rescan_vault<T: AsRef<Path>>(
|
|||
job_id: JobId,
|
||||
) -> Result<Vec<UpdatePathResult>> {
|
||||
let start = Instant::now();
|
||||
info!("[rescan] Vault rescan started.");
|
||||
|
||||
// Initialize types, etc...
|
||||
debug!("[rescan] Initializing DB types.");
|
||||
initialize_types(&pool)?;
|
||||
|
||||
// Disable syncing in SQLite for the duration of the import
|
||||
debug!("[rescan] Disabling SQLite synchronous mode");
|
||||
pool.get()?.execute("PRAGMA synchronous = OFF;")?;
|
||||
|
||||
// Walk through the vault, find all paths
|
||||
debug!("[rescan] Traversing vault directory");
|
||||
let path_entries: Vec<PathBuf> = WalkDir::new(&directory)
|
||||
.follow_links(true)
|
||||
.into_iter()
|
||||
|
@ -149,6 +153,7 @@ fn _rescan_vault<T: AsRef<Path>>(
|
|||
connection.transaction::<_, Error, _>(|| {
|
||||
file_set_valid(&connection, file.id, false)?;
|
||||
// remove_object(&connection, )?
|
||||
info!("Removed: {:?}", file.path);
|
||||
Ok(UpdatePathOutcome::Removed(PathBuf::from(file.path.clone())))
|
||||
})
|
||||
});
|
||||
|
@ -182,6 +187,7 @@ fn _rescan_vault<T: AsRef<Path>>(
|
|||
}
|
||||
|
||||
// Re-enable SQLite syncing
|
||||
debug!("[rescan] Re-enabling synchronous mode.");
|
||||
pool.get()?.execute("PRAGMA synchronous = NORMAL;")?;
|
||||
|
||||
info!(
|
||||
|
@ -203,7 +209,7 @@ fn _process_directory_entry<P: AsRef<Path>>(
|
|||
directory_path: &P,
|
||||
existing_files: &Arc<RwLock<Vec<models::File>>>,
|
||||
) -> UpdatePathResult {
|
||||
info!("Processing: {:?}", path);
|
||||
debug!("[rescan] Processing: {:?}", path);
|
||||
|
||||
// Prepare the data
|
||||
let connection = &db_pool.write().unwrap().get()?;
|
||||
|
@ -258,6 +264,7 @@ fn _process_directory_entry<P: AsRef<Path>>(
|
|||
|
||||
if let Some(idx) = maybe_existing_file {
|
||||
existing_files_write.swap_remove(idx);
|
||||
debug!("[rescan] Unchanged: {:?}", path);
|
||||
return Ok(UpdatePathOutcome::Unchanged(path));
|
||||
}
|
||||
}
|
||||
|
@ -336,6 +343,7 @@ fn _process_directory_entry<P: AsRef<Path>>(
|
|||
};
|
||||
insert_entry(connection, name_entry)?;
|
||||
|
||||
info!("[rescan] Added: {:?}", path);
|
||||
Ok(UpdatePathOutcome::Added(path.clone()))
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue