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