fn scan_tags(state: &mut AppState, mut parent: Option<&mut Tag>, p: impl AsRef<Path>) {
    let p = p.as_ref();
    for entry in fs::read_dir(p).expect("cannot access tags dir") {
        let entry = entry.expect("error scanning tags dir");
        let path = entry.path();
        let cpath = path.canonicalize().unwrap();
        if path.is_dir() {
            let mut tag = Tag {
                name: path
                    .strip_prefix(&state.tags_path)
                    .unwrap()
                    .to_string_lossy()
                    .to_string(),
                items: HashMap::default(),
            };
            scan_tags(state, Some(&mut tag), &path);
            state.tags.insert(cpath, tag);
        } else if let Some(item) = state.items_all.get_mut(&cpath) {
            if let Some(ref mut parent) = parent {
                parent.items.insert(cpath, path);
                item.tags.insert(p.canonicalize().unwrap());
            }
        }
    }
}
/// Scan tag directory
///
/// Must be run after items have been scanned.
///
/// Adds subdirectories to tags index.
/// Detects symlinks that point to a known item and adds item to the tag info.
Scan tag directory
Must be run after items have been scanned.

Adds subdirectories to tags index.
Detects symlinks that point to a known item and adds item to the tag info.
Scan tag directory Must be run after items have been scanned . Adds subdirectories to tags index . Detects symlinks that point to a known item and adds item to the tag info .
fn scan_tags(state: &mut AppState, mut parent: Option<&mut Tag>, p: impl AsRef<Path>) {
    let p = p.as_ref();
    for entry in fs::read_dir(p).expect("cannot access tags dir") {
        let entry = entry.expect("error scanning tags dir");
        let path = entry.path();
        let cpath = path.canonicalize().unwrap();
        if path.is_dir() {
            let mut tag = Tag {
                name: path
                    .strip_prefix(&state.tags_path)
                    .unwrap()
                    .to_string_lossy()
                    .to_string(),
                items: HashMap::default(),
            };
            scan_tags(state, Some(&mut tag), &path);
            state.tags.insert(cpath, tag);
        } else if let Some(item) = state.items_all.get_mut(&cpath) {
            if let Some(ref mut parent) = parent {
                parent.items.insert(cpath, path);
                item.tags.insert(p.canonicalize().unwrap());
            }
        }
    }
}
fn scan_tags ( state : & mut AppState , mut parent : Option < & mut Tag > , p : impl AsRef < Path > ) { let p = p . as_ref ( ) ; for entry in fs :: read_dir ( p ) . expect ( " " ) { let entry = entry . expect ( " " ) ; let path = entry . path ( ) ; let cpath = path . canonicalize ( ) . unwrap ( ) ; if path . is_dir ( ) { let mut tag = Tag { name : path . strip_prefix ( & state . tags_path ) . unwrap ( ) . to_string_lossy ( ) . to_string ( ) , items : HashMap :: default ( ) , } ; scan_tags ( state , Some ( & mut tag ) , & path ) ; state . tags . insert ( cpath , tag ) ; } else if let Some ( item ) = state . items_all . get_mut ( & cpath ) { if let Some ( ref mut parent ) = parent { parent . items . insert ( cpath , path ) ; item . tags . insert ( p . canonicalize ( ) . unwrap ( ) ) ; } } } }
Scan tag directory
Must be run after items have been scanned.
Scan tag directory Must be run after items have been scanned .
state
&mut AppState
parent
Option<&mut Tag>
p
impl AsRef<Path>