|
23 | 23 | use std::ops::{Bound, RangeBounds};
|
24 | 24 |
|
25 | 25 | use anyhow::Result;
|
26 |
| -use futures_lite::{io, Stream, StreamExt}; |
| 26 | +use futures_lite::{Stream, StreamExt}; |
27 | 27 | use quic_rpc::{client::BoxedConnector, Connector, RpcClient};
|
28 | 28 | use serde::{Deserialize, Serialize};
|
29 | 29 |
|
30 | 30 | use crate::{
|
31 | 31 | rpc::proto::{
|
32 |
| - tags::{DeleteRequest, ListRequest, SetRequest, SyncMode}, |
| 32 | + tags::{DeleteRequest, ListRequest, RenameRequest, SetRequest, SyncMode}, |
33 | 33 | RpcService,
|
34 | 34 | },
|
35 | 35 | BlobFormat, Hash, HashAndFormat, Tag,
|
@@ -235,13 +235,12 @@ where
|
235 | 235 | ///
|
236 | 236 | /// If the tag does not exist, this will return an error.
|
237 | 237 | pub async fn rename(&self, from: impl AsRef<[u8]>, to: impl AsRef<[u8]>) -> Result<()> {
|
238 |
| - let from = from.as_ref(); |
239 |
| - let to = to.as_ref(); |
240 |
| - let Some(old) = self.get(from.as_ref()).await? else { |
241 |
| - return Err(io::Error::new(io::ErrorKind::NotFound, "Tag not found").into()); |
242 |
| - }; |
243 |
| - self.set(to.as_ref(), old.hash_and_format()).await?; |
244 |
| - self.delete(from.as_ref()).await?; |
| 238 | + self.rpc |
| 239 | + .rpc(RenameRequest { |
| 240 | + from: Tag::from(from.as_ref()), |
| 241 | + to: Tag::from(to.as_ref()), |
| 242 | + }) |
| 243 | + .await??; |
245 | 244 | Ok(())
|
246 | 245 | }
|
247 | 246 |
|
|
0 commit comments