add mime type to filesystem update step
This commit is contained in:
parent
fc08a6578c
commit
c422f89d18
4 changed files with 131 additions and 16 deletions
124
Cargo.lock
generated
124
Cargo.lock
generated
|
@ -16,7 +16,7 @@ dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"parking_lot",
|
"parking_lot 0.11.1",
|
||||||
"pin-project 0.4.27",
|
"pin-project 0.4.27",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"tokio 0.2.25",
|
"tokio 0.2.25",
|
||||||
|
@ -241,7 +241,7 @@ dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"parking_lot",
|
"parking_lot 0.11.1",
|
||||||
"threadpool",
|
"threadpool",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ version = "0.7.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
|
checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr 2.3.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -585,6 +585,15 @@ dependencies = [
|
||||||
"vec_map",
|
"vec_map",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cloudabi"
|
||||||
|
version = "0.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "const_fn"
|
name = "const_fn"
|
||||||
version = "0.4.5"
|
version = "0.4.5"
|
||||||
|
@ -813,6 +822,12 @@ dependencies = [
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fixedbitset"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.0.20"
|
version = "1.0.20"
|
||||||
|
@ -932,7 +947,7 @@ dependencies = [
|
||||||
"futures-macro",
|
"futures-macro",
|
||||||
"futures-sink",
|
"futures-sink",
|
||||||
"futures-task",
|
"futures-task",
|
||||||
"memchr",
|
"memchr 2.3.4",
|
||||||
"pin-project-lite 0.2.4",
|
"pin-project-lite 0.2.4",
|
||||||
"pin-utils",
|
"pin-utils",
|
||||||
"proc-macro-hack",
|
"proc-macro-hack",
|
||||||
|
@ -1199,6 +1214,15 @@ version = "0.5.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
|
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lock_api"
|
||||||
|
version = "0.3.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75"
|
||||||
|
dependencies = [
|
||||||
|
"scopeguard",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lock_api"
|
name = "lock_api"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
|
@ -1244,6 +1268,15 @@ version = "2.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.3.4"
|
version = "2.3.4"
|
||||||
|
@ -1382,13 +1415,22 @@ dependencies = [
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nom"
|
||||||
|
version = "3.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "05aec50c70fd288702bcd93284a8444607f3292dbdf2a30de5ea5dcdbe72287b"
|
||||||
|
dependencies = [
|
||||||
|
"memchr 1.0.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nom"
|
name = "nom"
|
||||||
version = "4.2.3"
|
version = "4.2.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6"
|
checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr 2.3.4",
|
||||||
"version_check 0.1.5",
|
"version_check 0.1.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1454,6 +1496,16 @@ version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parking_lot"
|
||||||
|
version = "0.10.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e"
|
||||||
|
dependencies = [
|
||||||
|
"lock_api 0.3.4",
|
||||||
|
"parking_lot_core 0.7.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking_lot"
|
name = "parking_lot"
|
||||||
version = "0.11.1"
|
version = "0.11.1"
|
||||||
|
@ -1461,8 +1513,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
|
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"instant",
|
"instant",
|
||||||
"lock_api",
|
"lock_api 0.4.2",
|
||||||
"parking_lot_core",
|
"parking_lot_core 0.8.3",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parking_lot_core"
|
||||||
|
version = "0.7.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 0.1.10",
|
||||||
|
"cloudabi",
|
||||||
|
"libc",
|
||||||
|
"redox_syscall 0.1.57",
|
||||||
|
"smallvec",
|
||||||
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1474,7 +1540,7 @@ dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"instant",
|
"instant",
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall",
|
"redox_syscall 0.2.5",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
@ -1485,6 +1551,16 @@ version = "2.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
|
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "petgraph"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7"
|
||||||
|
dependencies = [
|
||||||
|
"fixedbitset",
|
||||||
|
"indexmap",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pin-project"
|
name = "pin-project"
|
||||||
version = "0.4.27"
|
version = "0.4.27"
|
||||||
|
@ -1598,7 +1674,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "545c5bc2b880973c9c10e4067418407a0ccaa3091781d1671d46eb35107cb26f"
|
checksum = "545c5bc2b880973c9c10e4067418407a0ccaa3091781d1671d46eb35107cb26f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"parking_lot",
|
"parking_lot 0.11.1",
|
||||||
"scheduled-thread-pool",
|
"scheduled-thread-pool",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1668,6 +1744,12 @@ dependencies = [
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "redox_syscall"
|
||||||
|
version = "0.1.57"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.2.5"
|
version = "0.2.5"
|
||||||
|
@ -1684,7 +1766,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
|
checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr 2.3.4",
|
||||||
"regex-syntax",
|
"regex-syntax",
|
||||||
"thread_local",
|
"thread_local",
|
||||||
]
|
]
|
||||||
|
@ -1741,7 +1823,7 @@ version = "0.2.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dc6f74fd1204073fa02d5d5d68bec8021be4c38690b61264b2fdb48083d0e7d7"
|
checksum = "dc6f74fd1204073fa02d5d5d68bec8021be4c38690b61264b2fdb48083d0e7d7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parking_lot",
|
"parking_lot 0.11.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2074,7 +2156,7 @@ dependencies = [
|
||||||
"iovec",
|
"iovec",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
"memchr",
|
"memchr 2.3.4",
|
||||||
"mio 0.6.23",
|
"mio 0.6.23",
|
||||||
"mio-uds",
|
"mio-uds",
|
||||||
"pin-project-lite 0.1.11",
|
"pin-project-lite 0.1.11",
|
||||||
|
@ -2093,7 +2175,7 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"mio 0.7.8",
|
"mio 0.7.8",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"parking_lot",
|
"parking_lot 0.11.1",
|
||||||
"pin-project-lite 0.2.4",
|
"pin-project-lite 0.2.4",
|
||||||
"signal-hook-registry",
|
"signal-hook-registry",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
|
@ -2145,6 +2227,19 @@ dependencies = [
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tree_magic"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b1d99367ce3e553a84738f73bd626ccca541ef90ae757fdcdc4cbe728e6cb629"
|
||||||
|
dependencies = [
|
||||||
|
"fnv",
|
||||||
|
"lazy_static",
|
||||||
|
"nom 3.2.1",
|
||||||
|
"parking_lot 0.10.2",
|
||||||
|
"petgraph",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "trust-dns-proto"
|
name = "trust-dns-proto"
|
||||||
version = "0.19.6"
|
version = "0.19.6"
|
||||||
|
@ -2271,6 +2366,7 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tiny-keccak",
|
"tiny-keccak",
|
||||||
|
"tree_magic",
|
||||||
"unsigned-varint",
|
"unsigned-varint",
|
||||||
"uuid",
|
"uuid",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
|
@ -2315,7 +2411,7 @@ version = "0.8.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c860ad1273f4eee7006cee05db20c9e60e5d24cba024a32e1094aa8e574f3668"
|
checksum = "c860ad1273f4eee7006cee05db20c9e60e5d24cba024a32e1094aa8e574f3668"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nom",
|
"nom 4.2.3",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
|
|
|
@ -41,6 +41,8 @@ unsigned-varint = { version = "^0", features = ["std"] }
|
||||||
uuid = { version = "0.8", features = ["v4"] }
|
uuid = { version = "0.8", features = ["v4"] }
|
||||||
walkdir = "2"
|
walkdir = "2"
|
||||||
|
|
||||||
|
tree_magic = "0.2.3"
|
||||||
|
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
webbrowser = "0.5.5"
|
webbrowser = "0.5.5"
|
||||||
xdg = "^2.1"
|
xdg = "^2.1"
|
||||||
|
|
|
@ -28,6 +28,7 @@ use std::time::Duration;
|
||||||
pub const TYPE_TYPE: &str = "TYPE";
|
pub const TYPE_TYPE: &str = "TYPE";
|
||||||
pub const TYPE_IS_ATTR: &str = "TYPE";
|
pub const TYPE_IS_ATTR: &str = "TYPE";
|
||||||
pub const TYPE_REQUIRES_ATTR: &str = "TYPE_REQUIRES";
|
pub const TYPE_REQUIRES_ATTR: &str = "TYPE_REQUIRES";
|
||||||
|
pub const TYPE_HAS_ATTR: &str = "TYPE_HAS";
|
||||||
pub const TYPE_ID_ATTR: &str = "TYPE_ID";
|
pub const TYPE_ID_ATTR: &str = "TYPE_ID";
|
||||||
pub const IS_OF_TYPE_ATTR: &str = "IS";
|
pub const IS_OF_TYPE_ATTR: &str = "IS";
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ use crate::addressing::Address;
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
bulk_retrieve_objects, file_set_valid, insert_entry, insert_file, query, retrieve_all_files,
|
bulk_retrieve_objects, file_set_valid, insert_entry, insert_file, query, retrieve_all_files,
|
||||||
DbPool, Entry, EntryQuery, EntryValue, InvariantEntry, Query, QueryComponent, QueryPart,
|
DbPool, Entry, EntryQuery, EntryValue, InvariantEntry, Query, QueryComponent, QueryPart,
|
||||||
DATABASE_FILENAME, IS_OF_TYPE_ATTR, TYPE_ADDR, TYPE_ID_ATTR, TYPE_IS_ATTR, TYPE_REQUIRES_ATTR,
|
DATABASE_FILENAME, IS_OF_TYPE_ATTR, TYPE_ADDR, TYPE_HAS_ATTR, TYPE_ID_ATTR, TYPE_IS_ATTR,
|
||||||
|
TYPE_REQUIRES_ATTR,
|
||||||
};
|
};
|
||||||
use crate::hash::Hashable;
|
use crate::hash::Hashable;
|
||||||
use crate::jobs::{Job, JobContainer, JobId};
|
use crate::jobs::{Job, JobContainer, JobId};
|
||||||
|
@ -37,6 +38,7 @@ lazy_static! {
|
||||||
const FILE_TYPE: &str = "FS_FILE";
|
const FILE_TYPE: &str = "FS_FILE";
|
||||||
const FILE_IDENTITY_KEY: &str = "FILE_IS";
|
const FILE_IDENTITY_KEY: &str = "FILE_IS";
|
||||||
const FILENAME_KEY: &str = "FILE_NAME";
|
const FILENAME_KEY: &str = "FILE_NAME";
|
||||||
|
const FILE_MIME_KEY: &str = "FILE_MIME";
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref FILE_TYPE_INVARIANT: InvariantEntry = InvariantEntry {
|
static ref FILE_TYPE_INVARIANT: InvariantEntry = InvariantEntry {
|
||||||
attribute: String::from(TYPE_IS_ATTR),
|
attribute: String::from(TYPE_IS_ATTR),
|
||||||
|
@ -72,6 +74,14 @@ fn initialize_types(pool: &DbPool) -> Result<()> {
|
||||||
value: EntryValue::Value(Value::from(FILE_IDENTITY_KEY)),
|
value: EntryValue::Value(Value::from(FILE_IDENTITY_KEY)),
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
insert_entry(
|
||||||
|
&pool.get()?,
|
||||||
|
Entry {
|
||||||
|
entity: FILE_TYPE_ADDR.clone(),
|
||||||
|
attribute: String::from(TYPE_HAS_ATTR),
|
||||||
|
value: EntryValue::Value(Value::from(FILE_MIME_KEY)),
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
// DIR_TYPE
|
// DIR_TYPE
|
||||||
insert_entry(&pool.get()?, Entry::try_from(&*DIR_TYPE_INVARIANT)?)?;
|
insert_entry(&pool.get()?, Entry::try_from(&*DIR_TYPE_INVARIANT)?)?;
|
||||||
|
@ -587,9 +597,15 @@ fn _process_directory_entry<P: AsRef<Path>>(
|
||||||
attribute: FILE_IDENTITY_KEY.to_string(),
|
attribute: FILE_IDENTITY_KEY.to_string(),
|
||||||
value: EntryValue::Address(Address::Hash(digest.clone())),
|
value: EntryValue::Address(Address::Hash(digest.clone())),
|
||||||
};
|
};
|
||||||
|
|
||||||
insert_entry(&connection, identity_entry)?;
|
insert_entry(&connection, identity_entry)?;
|
||||||
|
|
||||||
|
let mime_entry = Entry {
|
||||||
|
entity: file_address.clone(),
|
||||||
|
attribute: FILE_MIME_KEY.to_string(),
|
||||||
|
value: EntryValue::Value(Value::String(tree_magic::from_filepath(&path))),
|
||||||
|
};
|
||||||
|
insert_entry(&connection, mime_entry)?;
|
||||||
|
|
||||||
let dir_has_entry = Entry {
|
let dir_has_entry = Entry {
|
||||||
entity: parent_dir.clone(),
|
entity: parent_dir.clone(),
|
||||||
attribute: DIR_HAS_KEY.to_string(),
|
attribute: DIR_HAS_KEY.to_string(),
|
||||||
|
|
Loading…
Reference in a new issue