Something went wrong. Try again.
A modern, network-enabled music player platform built on Rockbox technology. rockboxd.tsiry-sandratraina.com
rust deno navidrome airplay libadwaita zig mpris snapcast mpd rockbox audio subsonic
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455use std::{collections::HashMap, fs, sync::Arc, thread};
use anyhow::Error;use rockbox_sys::types::tree::Entry;use tokio::sync::Mutex;
use crate::AUDIO_EXTENSIONS;
pub fn update_cache( fs_cache: Arc<Mutex<HashMap<String, Vec<Entry>>>>, path: &str, show_hidden: bool,) { let path = path.to_string(); thread::spawn(move || { let mut fs_cache = fs_cache.blocking_lock(); let mut entries = vec![];
for file in fs::read_dir(&path)? { let file = file?;
if file.metadata()?.is_file() && !AUDIO_EXTENSIONS.iter().any(|ext| { file.path() .to_string_lossy() .ends_with(&format!(".{}", ext)) }) { continue; }
if file.file_name().to_string_lossy().starts_with('.') && !show_hidden { continue; }
entries.push(Entry { name: file.path().to_string_lossy().to_string(), time_write: file .metadata()? .modified()? .duration_since(std::time::SystemTime::UNIX_EPOCH)? .as_secs() as u32, attr: match file.metadata()?.is_dir() { true => 0x10, false => 0, }, ..Default::default() }); }
fs_cache.insert(path, entries); Ok::<(), Error>(()) });}