chore(qconnect): checkpoint current poc state
cx
This commit is contained in:
92 files changed
+3886
-2433
No files matched your search
@@ -146,7 +146,8 @@ impl AudioCache {
|
||||
let mut state = self.state.lock().unwrap();
|
||||
|
||||
// Evict old entries to make room
|
||||
while state.current_size + size > self.max_size_bytes && !state.access_order.is_empty() {
|
||||
while state.current_size + size > self.max_size_bytes && !state.access_order.is_empty()
|
||||
{
|
||||
let oldest_id = state.access_order.remove(0);
|
||||
if let Some(track) = state.tracks.remove(&oldest_id) {
|
||||
state.current_size = state.current_size.saturating_sub(track.size_bytes);
|
||||
|
||||
@@ -58,5 +58,5 @@
|
||||
mod audio_cache;
|
||||
mod playback_cache;
|
||||
|
||||
pub use audio_cache::{AudioCache, CachedTrack, CacheStats};
|
||||
pub use audio_cache::{AudioCache, CacheStats, CachedTrack};
|
||||
pub use playback_cache::{PlaybackCache, PlaybackCacheStats};
|
||||
@@ -94,9 +94,8 @@ impl PlaybackCache {
|
||||
if let Some(id_str) = filename.strip_suffix(".audio") {
|
||||
if let Ok(track_id) = id_str.parse::<u64>() {
|
||||
let size = metadata.len();
|
||||
let last_accessed = metadata
|
||||
.accessed()
|
||||
.unwrap_or_else(|_| SystemTime::now());
|
||||
let last_accessed =
|
||||
metadata.accessed().unwrap_or_else(|_| SystemTime::now());
|
||||
|
||||
state.entries.insert(
|
||||
track_id,
|
||||
@@ -171,7 +170,11 @@ impl PlaybackCache {
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("Failed to open playback cache file for track {}: {}", track_id, e);
|
||||
log::warn!(
|
||||
"Failed to open playback cache file for track {}: {}",
|
||||
track_id,
|
||||
e
|
||||
);
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -232,7 +235,11 @@ impl PlaybackCache {
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("Failed to create playback cache file for track {}: {}", track_id, e);
|
||||
log::warn!(
|
||||
"Failed to create playback cache file for track {}: {}",
|
||||
track_id,
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user