video_hash_filesystem_cache/
generic_cache_if.rs1use std::path::Path;
2
3use generic_filesystem_cache::*;
4use vid_dup_finder_lib::*;
5
6use crate::*;
7
8pub struct GenericCacheIf {}
9
10impl GenericCacheIf {
11 pub fn new() -> Self {
12 Self {}
13 }
14}
15
16impl CacheInterface for GenericCacheIf {
17 type T = CacheEntry;
18
19 fn load(&self, src_path: impl AsRef<Path>) -> Self::T {
20 let new_entry = VideoHash::from_path_with_stats(src_path);
21
22 match &new_entry {
23 Ok((hash, _stats)) => info!(target: "hash_creation",
24 "inserting : {}",
25 hash.src_path().display()
26 ),
27 Err(HashCreationErrorKind::DetermineVideo { src_path, error }) => warn!(target: "hash_creation",
28 "not sure if video : {}. Error: {}",
29 src_path.display(),
30 error
31 ),
32 Err(HashCreationErrorKind::VideoLength(src_path)) => warn!(target: "hash_creation",
33 "Too short : {}",
34 src_path.display(),
35
36 ),
37 Err(HashCreationErrorKind::VideoProcessing { src_path, error }) => warn!(target: "hash_creation",
38 "Proc err : {} -- {}",
39 src_path.display(),
40 error
41 ),
42 }
43
44 CacheEntry::from(new_entry)
45 }
46}