diff options
author | metamuffin <metamuffin@disroot.org> | 2023-10-02 13:45:30 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-10-02 13:45:30 +0200 |
commit | a7513d5f0db18570cc7db405810ce66cab6475e4 (patch) | |
tree | 350581a2ef1b4ff0ba6b2b867fa918ed39d70647 /base/src | |
parent | 3da60b245427a7409e17638bd78783a7ff7154f7 (diff) | |
download | jellything-a7513d5f0db18570cc7db405810ce66cab6475e4.tar jellything-a7513d5f0db18570cc7db405810ce66cab6475e4.tar.bz2 jellything-a7513d5f0db18570cc7db405810ce66cab6475e4.tar.zst |
broken transcode
Diffstat (limited to 'base/src')
-rw-r--r-- | base/src/cache.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/base/src/cache.rs b/base/src/cache.rs index 7705a14..ee13b73 100644 --- a/base/src/cache.rs +++ b/base/src/cache.rs @@ -3,7 +3,7 @@ use anyhow::{anyhow, Context}; use base64::Engine; use bincode::{Decode, Encode}; use jellycommon::AssetLocation; -use log::info; +use log::{info, warn}; use std::{ any::Any, collections::{BTreeMap, HashMap}, @@ -54,7 +54,14 @@ where let f = tokio::fs::File::create(location.path()) .await .context("creating new cache file")?; - generate(f).await?; + match generate(f).await { + Ok(()) => (), + Err(e) => { + warn!("cache generation failed, unlinking entry"); + tokio::fs::remove_file(location.path()).await?; + return Err(e); + } + } } drop(_guard); Ok(location) @@ -70,7 +77,14 @@ where let exists = location.path().exists(); if !exists { let f = std::fs::File::create(location.path()).context("creating new cache file")?; - generate(f)?; + match generate(f) { + Ok(()) => (), + Err(e) => { + warn!("cache generation failed, unlinking entry"); + std::fs::remove_file(location.path())?; + return Err(e); + } + } } drop(_guard); Ok(location) |