From ccaf10b4a6f7768294e41fcb6fbcd768a1e1c143 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Mon, 11 Dec 2023 22:11:01 +0200 Subject: refactor(tvix/*store/sled): make ::new() more generic We don't really require the Path to be a PathBuf, we don't even require it to be a Path, we only need it to be AsRef>. This removes some conversion in the from_addr cases, which can just reuse `url.path()` (a `&str`). Change-Id: I38d536dbaf0b44421e41f211a9ad2b13605179e9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10258 Autosubmit: flokli Reviewed-by: raitobezarius Tested-by: BuildkiteCI --- tvix/castore/src/blobservice/from_addr.rs | 3 +-- tvix/castore/src/blobservice/sled.rs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'tvix/castore/src/blobservice') diff --git a/tvix/castore/src/blobservice/from_addr.rs b/tvix/castore/src/blobservice/from_addr.rs index 106edce04d1a..97e185464d3c 100644 --- a/tvix/castore/src/blobservice/from_addr.rs +++ b/tvix/castore/src/blobservice/from_addr.rs @@ -44,8 +44,7 @@ pub async fn from_addr(uri: &str) -> Result, crate::Error> )); } return Ok(Arc::new( - SledBlobService::new(url.path().into()) - .map_err(|e| Error::StorageError(e.to_string()))?, + SledBlobService::new(url.path()).map_err(|e| Error::StorageError(e.to_string()))?, )); } else if url.scheme().starts_with("grpc+") { // schemes starting with grpc+ go to the GRPCPathInfoService. diff --git a/tvix/castore/src/blobservice/sled.rs b/tvix/castore/src/blobservice/sled.rs index a6fdbac499b0..f7bf33e8c50f 100644 --- a/tvix/castore/src/blobservice/sled.rs +++ b/tvix/castore/src/blobservice/sled.rs @@ -2,7 +2,7 @@ use super::{BlobReader, BlobService, BlobWriter}; use crate::{B3Digest, Error}; use std::{ io::{self, Cursor, Write}, - path::PathBuf, + path::Path, task::Poll, }; use tonic::async_trait; @@ -14,7 +14,7 @@ pub struct SledBlobService { } impl SledBlobService { - pub fn new(p: PathBuf) -> Result { + pub fn new>(p: P) -> Result { let config = sled::Config::default() .use_compression(false) // is a required parameter .path(p); -- cgit 1.4.1