correction for lazy playlist and lazy cache

This commit is contained in:
2025-12-15 11:18:58 +01:00
parent 4bc80dfd08
commit 90399b408a
28 changed files with 349 additions and 39126 deletions

View File

@@ -4,7 +4,7 @@ use std::{
sync::Arc,
};
use crate::{CacheConfig, DB};
use crate::{cache::is_lazy_pk, CacheConfig, DB};
/// Trait générique pour les caches de fichiers
///
@@ -145,6 +145,29 @@ pub trait FileCache<C: CacheConfig>: Send + Sync {
/// Ceci permet le progressive caching: les fichiers en cours de download sont acceptés
/// dès que le prebuffer est atteint, sans attendre le marker de completion.
async fn is_valid_pk(&self, pk: &str) -> bool {
if is_lazy_pk(pk) {
match self.get_database().has_lazy_entry(pk) {
Ok(true) => {
tracing::debug!(
"is_valid_pk({}): Lazy entry present in DB, download deferred",
pk
);
return true;
}
Ok(false) => {
tracing::warn!(
"is_valid_pk({}): Lazy pk not registered in DB, rejecting",
pk
);
return false;
}
Err(e) => {
tracing::error!("is_valid_pk({}): Error while checking lazy pk: {}", pk, e);
return false;
}
}
}
if self.get_database().get(pk, false).is_err() {
tracing::debug!("is_valid_pk({}): DB entry not found", pk);
return false;