switch from tree_magic to mini_tree_magic
parent
a608659baa
commit
5f8182e9b7
|
@ -18,7 +18,7 @@ dependencies = [
|
|||
"futures-util",
|
||||
"log",
|
||||
"once_cell",
|
||||
"parking_lot 0.11.2",
|
||||
"parking_lot",
|
||||
"pin-project 0.4.28",
|
||||
"smallvec",
|
||||
"tokio 0.2.25",
|
||||
|
@ -243,7 +243,7 @@ dependencies = [
|
|||
"lazy_static",
|
||||
"log",
|
||||
"num_cpus",
|
||||
"parking_lot 0.11.2",
|
||||
"parking_lot",
|
||||
"threadpool",
|
||||
]
|
||||
|
||||
|
@ -363,7 +363,7 @@ version = "0.7.18"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
|
||||
dependencies = [
|
||||
"memchr 2.4.1",
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -493,7 +493,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"memchr 2.4.1",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
]
|
||||
|
||||
|
@ -512,6 +512,12 @@ version = "3.8.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c"
|
||||
|
||||
[[package]]
|
||||
name = "bytecount"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72feb31ffc86498dacdbd0fcebb56138e7177a8cc5cea4516031d15ae85a742e"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.4.3"
|
||||
|
@ -586,15 +592,6 @@ dependencies = [
|
|||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cloudabi"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "const_fn"
|
||||
version = "0.4.8"
|
||||
|
@ -854,9 +851,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "fixedbitset"
|
||||
version = "0.2.0"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
|
||||
checksum = "398ea4fabe40b9b0d885340a2a991a44c8a645624075ad966d21f88688e2b69e"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
|
@ -979,7 +976,7 @@ dependencies = [
|
|||
"futures-macro",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"memchr 2.4.1",
|
||||
"memchr",
|
||||
"pin-project-lite 0.2.7",
|
||||
"pin-utils",
|
||||
"slab",
|
||||
|
@ -1256,15 +1253,6 @@ version = "0.5.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "lock_api"
|
||||
version = "0.4.5"
|
||||
|
@ -1319,15 +1307,6 @@ version = "2.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.4.1"
|
||||
|
@ -1380,6 +1359,12 @@ dependencies = [
|
|||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.4.4"
|
||||
|
@ -1465,25 +1450,27 @@ dependencies = [
|
|||
"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]]
|
||||
name = "nom"
|
||||
version = "4.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6"
|
||||
dependencies = [
|
||||
"memchr 2.4.1",
|
||||
"memchr",
|
||||
"version_check 0.1.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
"version_check 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nonempty"
|
||||
version = "0.6.0"
|
||||
|
@ -1550,16 +1537,6 @@ dependencies = [
|
|||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[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]]
|
||||
name = "parking_lot"
|
||||
version = "0.11.2"
|
||||
|
@ -1567,22 +1544,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
|
||||
dependencies = [
|
||||
"instant",
|
||||
"lock_api 0.4.5",
|
||||
"parking_lot_core 0.8.5",
|
||||
]
|
||||
|
||||
[[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",
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1594,7 +1557,7 @@ dependencies = [
|
|||
"cfg-if 1.0.0",
|
||||
"instant",
|
||||
"libc",
|
||||
"redox_syscall 0.2.10",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
@ -1607,9 +1570,9 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
|
|||
|
||||
[[package]]
|
||||
name = "petgraph"
|
||||
version = "0.5.1"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7"
|
||||
checksum = "4a13a2fa9d0b63e5f22328828741e523766fff0ee9e779316902290dff3f824f"
|
||||
dependencies = [
|
||||
"fixedbitset",
|
||||
"indexmap",
|
||||
|
@ -1722,7 +1685,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "545c5bc2b880973c9c10e4067418407a0ccaa3091781d1671d46eb35107cb26f"
|
||||
dependencies = [
|
||||
"log",
|
||||
"parking_lot 0.11.2",
|
||||
"parking_lot",
|
||||
"scheduled-thread-pool",
|
||||
]
|
||||
|
||||
|
@ -1829,12 +1792,6 @@ dependencies = [
|
|||
"rand_core 0.3.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.57"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.10"
|
||||
|
@ -1851,7 +1808,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
|
||||
dependencies = [
|
||||
"getrandom 0.2.3",
|
||||
"redox_syscall 0.2.10",
|
||||
"redox_syscall",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1861,7 +1818,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr 2.4.1",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
|
@ -1935,7 +1892,7 @@ version = "0.2.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc6f74fd1204073fa02d5d5d68bec8021be4c38690b61264b2fdb48083d0e7d7"
|
||||
dependencies = [
|
||||
"parking_lot 0.11.2",
|
||||
"parking_lot",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2275,7 +2232,7 @@ dependencies = [
|
|||
"iovec",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"memchr 2.4.1",
|
||||
"memchr",
|
||||
"mio 0.6.23",
|
||||
"mio-uds",
|
||||
"pin-project-lite 0.1.12",
|
||||
|
@ -2293,7 +2250,7 @@ dependencies = [
|
|||
"libc",
|
||||
"mio 0.7.14",
|
||||
"once_cell",
|
||||
"parking_lot 0.11.2",
|
||||
"parking_lot",
|
||||
"pin-project-lite 0.2.7",
|
||||
"signal-hook-registry",
|
||||
"winapi 0.3.9",
|
||||
|
@ -2346,15 +2303,16 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree_magic"
|
||||
version = "0.2.3"
|
||||
name = "tree_magic_mini"
|
||||
version = "3.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1d99367ce3e553a84738f73bd626ccca541ef90ae757fdcdc4cbe728e6cb629"
|
||||
checksum = "7a7581560dc616314f7d73e81419c783d93a92e7fc7331b3041ff57bab240ea6"
|
||||
dependencies = [
|
||||
"bytecount",
|
||||
"fnv",
|
||||
"lazy_static",
|
||||
"nom 3.2.1",
|
||||
"parking_lot 0.10.2",
|
||||
"nom 7.1.0",
|
||||
"once_cell",
|
||||
"petgraph",
|
||||
]
|
||||
|
||||
|
@ -2485,7 +2443,7 @@ dependencies = [
|
|||
"tempdir",
|
||||
"thiserror",
|
||||
"tiny-keccak",
|
||||
"tree_magic",
|
||||
"tree_magic_mini",
|
||||
"unsigned-varint",
|
||||
"uuid",
|
||||
"walkdir",
|
||||
|
|
|
@ -50,7 +50,7 @@ unsigned-varint = { version = "^0", features = ["std"] }
|
|||
uuid = { version = "0.8", features = ["v4"] }
|
||||
walkdir = "2"
|
||||
|
||||
tree_magic = "0.2.3"
|
||||
tree_magic_mini = "3.0.2"
|
||||
|
||||
dotenv = "0.15.0"
|
||||
xdg = "^2.1"
|
||||
|
|
|
@ -325,11 +325,11 @@ fn _process_directory_entry<P: AsRef<Path>>(
|
|||
value: EntryValue::Value(Value::from(size)),
|
||||
};
|
||||
|
||||
let mime_entry = Entry {
|
||||
let mime_entry = tree_magic_mini::from_filepath(&path).map(|mime_type| Entry {
|
||||
entity: Address::Hash(file_hash.clone()),
|
||||
attribute: FILE_MIME_KEY.to_string(),
|
||||
value: EntryValue::Value(Value::String(tree_magic::from_filepath(&path))),
|
||||
};
|
||||
value: EntryValue::Value(Value::String(mime_type.to_string())),
|
||||
});
|
||||
|
||||
// Finally, add the appropriate entries w/r/t virtual filesystem location
|
||||
let components = normalized_path.components().collect::<Vec<Component>>();
|
||||
|
@ -350,7 +350,9 @@ fn _process_directory_entry<P: AsRef<Path>>(
|
|||
|
||||
connection.insert_entry(type_entry)?;
|
||||
connection.insert_entry(size_entry)?;
|
||||
connection.insert_entry(mime_entry)?;
|
||||
if let Some(mime_entry) = mime_entry {
|
||||
connection.insert_entry(mime_entry)?;
|
||||
}
|
||||
|
||||
let dir_has_entry = Entry {
|
||||
entity: parent_dir.clone(),
|
||||
|
|
|
@ -53,14 +53,11 @@ impl ThumbnailStore {
|
|||
let connection = self.db.connection()?;
|
||||
let files = connection.retrieve_file(hash)?;
|
||||
if let Some(file) = files.get(0) {
|
||||
// because tree_magic panics on nonexistent paths, poisioning our mutexes
|
||||
if !file.path.exists() {
|
||||
return Err(anyhow!("File doesn't exist - shouldn't happen!"));
|
||||
}
|
||||
|
||||
let data = match tree_magic::from_filepath(&file.path) {
|
||||
tm if tm.starts_with("text") => Ok(TextPath(&file.path).get_thumbnail()?),
|
||||
unknown => Err(anyhow!("No capability for {:?} thumbnails.", unknown)),
|
||||
let data = match tree_magic_mini::from_filepath(&file.path) {
|
||||
Some(tm) if tm.starts_with("text") => Ok(TextPath(&file.path).get_thumbnail()?),
|
||||
Some(unknown) => Err(anyhow!("No capability for {:?} thumbnails.", unknown)),
|
||||
_ => Err(anyhow!("Unknown file type, or file doesn't exist."))
|
||||
}?;
|
||||
|
||||
std::fs::create_dir_all(&self.path)?;
|
||||
|
|
Loading…
Reference in New Issue