From de0cae11b67b3a1475a142e3ab2f0a61c2e561de Mon Sep 17 00:00:00 2001 From: Pasha Date: Mon, 4 Mar 2024 10:27:07 +0300 Subject: [PATCH] feat: Development --- Cargo.lock | 2 +- bin/main.rs | 26 +------------------------- src/iroh_node.rs | 7 ------- src/storage.rs | 15 --------------- trident-py/pyproject.toml | 2 +- trident-py/trident/client.py | 5 +---- 6 files changed, 4 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6485244..4594a42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5262,7 +5262,7 @@ dependencies = [ [[package]] name = "trident-storage" -version = "0.0.15" +version = "0.0.16" dependencies = [ "anyhow", "async-stream", diff --git a/bin/main.rs b/bin/main.rs index b414cf9..cc7082c 100644 --- a/bin/main.rs +++ b/bin/main.rs @@ -2,10 +2,9 @@ use axum::body::Body; use axum::extract::{Query, Request}; use axum::http::StatusCode; use axum::response::{IntoResponse, Response}; -use axum::routing::{delete, head, post, put}; +use axum::routing::{delete, get, post, put}; use axum::{ extract::{Path, State}, - routing::get, Json, Router, }; use clap::{Parser, Subcommand}; @@ -97,12 +96,6 @@ struct AppState { config: Arc>, config_path: PathBuf, } - -#[derive(Serialize)] -struct TableExistsResponse { - pub exists: bool, -} - #[derive(Serialize)] struct TablesExistsResponse { pub exists: bool, @@ -160,7 +153,6 @@ async fn app() -> Result<(), Error> { .route("/tables/:table/", get(table_ls)) .route("/tables/:table/share/", get(table_share)) .route("/tables/:table/*key", get(table_get)) - .route("/tables/:table/*key", head(table_exists)) .route("/tables/:table/*key", put(table_insert)) .route("/tables/:table/*key", delete(table_delete)) .route("/tables/foreign_insert/", post(table_foreign_insert)) @@ -466,22 +458,6 @@ async fn table_delete( } } -async fn table_exists( - State(state): State, - Path((table, key)): Path<(String, String)>, -) -> Response { - match state - .iroh_node - .read() - .await - .table_exists(&table, &key) - .await - { - Ok(exists) => Json(TableExistsResponse { exists }).into_response(), - Err(e) => e.into_response(), - } -} - async fn table_ls(State(state): State, Path(table): Path) -> Response { match state.iroh_node.read().await.table_keys(&table) { Some(stream) => Response::builder().body(Body::from_stream(stream)).unwrap(), diff --git a/src/iroh_node.rs b/src/iroh_node.rs index 25f4090..6e69d2f 100644 --- a/src/iroh_node.rs +++ b/src/iroh_node.rs @@ -408,13 +408,6 @@ impl IrohNode { } } - pub async fn table_exists(&self, table_name: &str, key: &str) -> Result { - match self.table_storages.get(table_name) { - Some(table_storage) => Ok(table_storage.exists(key).await?.is_some()), - None => Err(Error::missing_table(table_name)), - } - } - pub fn table_keys(&self, table_name: &str) -> Option>> { self.table_storages.get(table_name).cloned().map_or_else( || None, diff --git a/src/storage.rs b/src/storage.rs index 68a1687..4017005 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -351,21 +351,6 @@ impl Storage { }) } - pub async fn exists(&self, key: &str) -> Result> { - for file_shard_config in self.hash_ring.range(key, 1) { - let file_shard = &self.shards[&file_shard_config.name]; - if file_shard - .exists(key) - .await - .map_err(Error::io_error)? - .is_some() - { - return Ok(Some(file_shard.get_path_for(key))); - } - } - Ok(None) - } - pub fn iroh_doc(&self) -> &IrohDoc { &self.iroh_doc } diff --git a/trident-py/pyproject.toml b/trident-py/pyproject.toml index d1ec7e4..f59c105 100644 --- a/trident-py/pyproject.toml +++ b/trident-py/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "izihawa-trident-client" -version = "1.1.0" +version = "1.1.1" description = "" authors = ["Pasha Podolsky "] readme = "README.md" diff --git a/trident-py/trident/client.py b/trident-py/trident/client.py index 945256e..9f50983 100644 --- a/trident-py/trident/client.py +++ b/trident-py/trident/client.py @@ -114,7 +114,4 @@ async def table_ls(self, table) -> typing.AsyncGenerator[str, None]: async def table_exists(self, table: str, key: str) -> bool: url = f"/tables/{table}/{key}" response = await self.head(url) - if response is None: - return False - response = await response.json() - return response["exists"] + return response is not None