remove ensure_invariant now that it's unnecessary
parent
2ffbd4934b
commit
e38bab5957
|
@ -647,13 +647,6 @@ pub fn insert_entry<C: Connection<Backend = Sqlite>>(
|
|||
Ok(Address::Hash(entry.hash()?))
|
||||
}
|
||||
|
||||
pub fn ensure_invariant<C: Connection<Backend = Sqlite>>(
|
||||
connection: &C,
|
||||
invariant: &InvariantEntry,
|
||||
) -> Result<Address> {
|
||||
insert_entry(connection, Entry::try_from(invariant)?)
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ConnectionOptions {
|
||||
pub enable_foreign_keys: bool,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::addressing::Address;
|
||||
use crate::database::{
|
||||
bulk_retrieve_objects, ensure_invariant, file_set_valid, insert_entry, insert_file, query,
|
||||
retrieve_all_files, Addressable, DbPool, Entry, EntryQuery, EntryValue, InvariantEntry, Query,
|
||||
QueryComponent, QueryPart, DATABASE_FILENAME, IS_TYPE_ATTR, TYPE_ATTR, TYPE_HAS_ATTR,
|
||||
bulk_retrieve_objects, file_set_valid, insert_entry, insert_file, query, retrieve_all_files,
|
||||
Addressable, DbPool, Entry, EntryQuery, EntryValue, InvariantEntry, Query, QueryComponent,
|
||||
QueryPart, DATABASE_FILENAME, IS_TYPE_ATTR, TYPE_ATTR, TYPE_HAS_ATTR,
|
||||
};
|
||||
use crate::hash::Hashable;
|
||||
use crate::jobs::{Job, JobContainer, JobId};
|
||||
|
@ -15,6 +15,7 @@ use diesel::Connection;
|
|||
use log::{error, info, trace};
|
||||
use rayon::prelude::*;
|
||||
use serde_json::Value;
|
||||
use std::convert::TryFrom;
|
||||
use std::path::{Component, Path, PathBuf};
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::time::{Instant, UNIX_EPOCH};
|
||||
|
@ -344,7 +345,7 @@ fn _rescan_vault<T: AsRef<Path>>(
|
|||
let start = Instant::now();
|
||||
|
||||
// Initialize types, etc...
|
||||
let file_type = ensure_invariant(&pool.get()?, &FILE_TYPE_INVARIANT)?;
|
||||
let file_type = insert_entry(&pool.get()?, Entry::try_from(&*FILE_TYPE_INVARIANT)?)?;
|
||||
for attr in &[FILE_IDENTITY_KEY, FILENAME_KEY] {
|
||||
insert_entry(
|
||||
&pool.get()?,
|
||||
|
@ -356,7 +357,7 @@ fn _rescan_vault<T: AsRef<Path>>(
|
|||
)?;
|
||||
}
|
||||
|
||||
let dir_type = ensure_invariant(&pool.get()?, &DIR_TYPE_INVARIANT)?;
|
||||
let dir_type = insert_entry(&pool.get()?, Entry::try_from(&*DIR_TYPE_INVARIANT)?)?;
|
||||
insert_entry(
|
||||
&pool.get()?,
|
||||
Entry {
|
||||
|
@ -541,9 +542,10 @@ fn _process_directory_entry<P: AsRef<Path>>(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::filesystem::{UDirectory, UPath};
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::filesystem::{UDirectory, UPath};
|
||||
|
||||
#[test]
|
||||
fn test_path_codec() {
|
||||
let path = UPath(vec![
|
||||
|
|
Loading…
Reference in New Issue