media: add MediaFileKey wrapper

One more win in the fight against the Vec<u8>s
This commit is contained in:
Lambda 2024-08-11 17:11:48 +00:00
parent 84850a163d
commit 1ccb1e572b
5 changed files with 38 additions and 13 deletions

View file

@ -35,6 +35,7 @@ use trust_dns_resolver::TokioAsyncResolver;
use crate::{
api::server_server::FedDest,
observability::FilterReloadHandles,
service::media::MediaFileKey,
services,
utils::on_demand_hashmap::{OnDemandHashMap, TokenSet},
Config, Error, Result,
@ -506,11 +507,11 @@ impl Service {
r
}
pub(crate) fn get_media_file(&self, key: &[u8]) -> PathBuf {
pub(crate) fn get_media_file(&self, key: &MediaFileKey) -> PathBuf {
let mut r = PathBuf::new();
r.push(self.config.database.path.clone());
r.push("media");
r.push(general_purpose::URL_SAFE_NO_PAD.encode(key));
r.push(general_purpose::URL_SAFE_NO_PAD.encode(key.as_bytes()));
r
}