From ba4e02c3ac1e5ff093268874e5dc684596e9f541 Mon Sep 17 00:00:00 2001 From: Yureka Date: Wed, 7 Aug 2024 19:18:25 +0200 Subject: feat(tvix/dirsvc/Cache): support building from url Change-Id: I80121319795319bb977427efeca3666c6b87a1b7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12147 Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/castore/src/directoryservice/combinators.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'tvix/castore') diff --git a/tvix/castore/src/directoryservice/combinators.rs b/tvix/castore/src/directoryservice/combinators.rs index 4283142231f9..84216de92f90 100644 --- a/tvix/castore/src/directoryservice/combinators.rs +++ b/tvix/castore/src/directoryservice/combinators.rs @@ -152,11 +152,12 @@ pub struct CacheConfig { impl TryFrom for CacheConfig { type Error = Box; - fn try_from(_url: url::Url) -> Result { - Err(Error::StorageError( - "Instantiating a CombinedDirectoryService from a url is not supported".into(), - ) - .into()) + fn try_from(url: url::Url) -> Result { + // cache doesn't support host or path in the URL. + if url.has_host() || !url.path().is_empty() { + return Err(Error::StorageError("invalid url".to_string()).into()); + } + Ok(serde_qs::from_str(url.query().unwrap_or_default())?) } } -- cgit 1.4.1