diff --git a/Cargo.toml b/Cargo.toml index abe0eec7..8b5e4475 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,7 +96,7 @@ futures-util = "0.3.30" testdir = "0.9.1" [features] -default = ["fs-store", "net_protocol"] +default = ["fs-store", "net_protocol", "rpc"] downloader = ["dep:parking_lot", "tokio-util/time", "dep:hashlink"] net_protocol = ["downloader", "dep:futures-util"] fs-store = ["dep:reflink-copy", "redb", "dep:tempfile"] diff --git a/src/lib.rs b/src/lib.rs index 7091ad79..fc9e397b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,6 +22,17 @@ //! The [downloader] module provides a component to download blobs from //! multiple sources and store them in a store. //! +//! # Feature flags +//! +//! - rpc: Enable the rpc server and client. Enabled by default. +//! - net_protocol: Enable the network protocol. Enabled by default. +//! - downloader: Enable the downloader. Enabled by default. +//! - fs-store: Enable the filesystem store. Enabled by default. +//! +//! - cli: Enable the cli. Disabled by default. +//! - example-iroh: dependencies for examples in this crate. Disabled by default. +//! - test: test utilities. Disabled by default. +//! //! [BLAKE3]: https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf //! [iroh]: https://docs.rs/iroh #![deny(missing_docs, rustdoc::broken_intra_doc_links)] diff --git a/src/rpc/client/tags.rs b/src/rpc/client/tags.rs index 595a139d..cd9000ea 100644 --- a/src/rpc/client/tags.rs +++ b/src/rpc/client/tags.rs @@ -23,13 +23,13 @@ use std::ops::{Bound, RangeBounds}; use anyhow::Result; -use futures_lite::{io, Stream, StreamExt}; +use futures_lite::{Stream, StreamExt}; use quic_rpc::{client::BoxedConnector, Connector, RpcClient}; use serde::{Deserialize, Serialize}; use crate::{ rpc::proto::{ - tags::{DeleteRequest, ListRequest, SetRequest, SyncMode}, + tags::{DeleteRequest, ListRequest, RenameRequest, SetRequest, SyncMode}, RpcService, }, BlobFormat, Hash, HashAndFormat, Tag, @@ -235,13 +235,12 @@ where /// /// If the tag does not exist, this will return an error. pub async fn rename(&self, from: impl AsRef<[u8]>, to: impl AsRef<[u8]>) -> Result<()> { - let from = from.as_ref(); - let to = to.as_ref(); - let Some(old) = self.get(from.as_ref()).await? else { - return Err(io::Error::new(io::ErrorKind::NotFound, "Tag not found").into()); - }; - self.set(to.as_ref(), old.hash_and_format()).await?; - self.delete(from.as_ref()).await?; + self.rpc + .rpc(RenameRequest { + from: Tag::from(from.as_ref()), + to: Tag::from(to.as_ref()), + }) + .await??; Ok(()) } diff --git a/src/store/fs.rs b/src/store/fs.rs index 091d674c..0628dc18 100644 --- a/src/store/fs.rs +++ b/src/store/fs.rs @@ -2043,7 +2043,7 @@ impl ActorState { fn rename_tag(&mut self, tables: &mut Tables, from: Tag, to: Tag) -> ActorResult<()> { let value = tables .tags - .get(from)? + .remove(from)? .ok_or_else(|| { ActorError::Io(io::Error::new(io::ErrorKind::NotFound, "tag not found")) })?