diff options
author | Yureka <tvl@yuka.dev> | 2024-08-07T17·18+0200 |
---|---|---|
committer | yuka <tvl@yuka.dev> | 2024-10-10T12·53+0000 |
commit | ba4e02c3ac1e5ff093268874e5dc684596e9f541 (patch) | |
tree | c44a4cd6baac23b07f3d3abf75d71f9294469106 | |
parent | 07bf8a0b6d4541e1982968c03279a0491056ac2f (diff) |
feat(tvix/dirsvc/Cache): support building from url r/8784
Change-Id: I80121319795319bb977427efeca3666c6b87a1b7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12147 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
-rw-r--r-- | tvix/castore/src/directoryservice/combinators.rs | 11 |
1 files changed, 6 insertions, 5 deletions
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<url::Url> for CacheConfig { type Error = Box<dyn std::error::Error + Send + Sync>; - fn try_from(_url: url::Url) -> Result<Self, Self::Error> { - Err(Error::StorageError( - "Instantiating a CombinedDirectoryService from a url is not supported".into(), - ) - .into()) + fn try_from(url: url::Url) -> Result<Self, Self::Error> { + // 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())?) } } |