mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Fix invalid state after cache clear
This commit is contained in:
parent
29f874e390
commit
fb2280798a
@ -21,27 +21,34 @@ impl Transcoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn clean_old_transcode(&self) {
|
fn clean_old_transcode(&self) {
|
||||||
for info in self.running.write().unwrap().values_mut() {
|
self.running.write().unwrap().retain(|_, info| {
|
||||||
if SystemTime::now()
|
if SystemTime::now()
|
||||||
.duration_since(*info.last_used.read().unwrap())
|
.duration_since(*info.last_used.read().unwrap())
|
||||||
.is_ok_and(|d| d > Duration::new(4 * 60 * 60, 0))
|
.is_ok_and(|d| d > Duration::new(4 * 60 * 60, 0))
|
||||||
{
|
{
|
||||||
_ = info.job.interrupt();
|
_ = info.job.interrupt();
|
||||||
_ = std::fs::remove_dir_all(get_cache_path_from_uuid(&info.uuid));
|
_ = std::fs::remove_dir_all(get_cache_path_from_uuid(&info.uuid));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clean_old_audio_transcode(&self) {
|
fn clean_old_audio_transcode(&self) {
|
||||||
for ((path, idx), info) in self.audio_jobs.write().unwrap().iter_mut() {
|
self.audio_jobs
|
||||||
|
.write()
|
||||||
|
.unwrap()
|
||||||
|
.retain(|(path, idx), info| {
|
||||||
if SystemTime::now()
|
if SystemTime::now()
|
||||||
.duration_since(*info.last_used.read().unwrap())
|
.duration_since(*info.last_used.read().unwrap())
|
||||||
.is_ok_and(|d| d > Duration::new(4 * 60 * 60, 0))
|
.is_ok_and(|d| d > Duration::new(4 * 60 * 60, 0))
|
||||||
{
|
{
|
||||||
_ = info.job.interrupt();
|
_ = info.job.interrupt();
|
||||||
_ = std::fs::remove_dir_all(get_audio_path(path, *idx));
|
_ = std::fs::remove_dir_all(get_audio_path(path, *idx));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn build_master(&self, resource: String, slug: String) -> Option<String> {
|
pub async fn build_master(&self, resource: String, slug: String) -> Option<String> {
|
||||||
|
@ -231,7 +231,7 @@ pub async fn transcode_video(
|
|||||||
show: (path, quality),
|
show: (path, quality),
|
||||||
job: child,
|
job: child,
|
||||||
uuid,
|
uuid,
|
||||||
last_used: RwLock::new(SystemTime::now())
|
last_used: RwLock::new(SystemTime::now()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user