Skip to content

Commit

Permalink
[feat] Development
Browse files Browse the repository at this point in the history
  • Loading branch information
ppodolsky committed Apr 26, 2024
1 parent 1008ed4 commit 7fb0b0e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
16 changes: 13 additions & 3 deletions bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use tokio::sync::RwLock;
use tokio_util::io::{ReaderStream, StreamReader};
use tokio_util::sync::CancellationToken;
use tokio_util::task::TaskTracker;
use tower_http::trace::{self, TraceLayer};
use tower_http::cors::CorsLayer;
use tower_http::trace::{self, TraceLayer};
use tracing::{info, info_span, Instrument, Level};
use tracing_subscriber::EnvFilter;
use trident_storage::config::{Config, TableConfig};
Expand Down Expand Up @@ -505,13 +505,23 @@ async fn table_get(
Ok(Some((reader, file_size, hash))) => match method {
Method::HEAD => Response::builder()
.header("Content-Length", file_size)
.header("Content-Type", mime_guess::from_ext(&key).first_or_octet_stream().to_string())
.header(
"Content-Type",
mime_guess::from_ext(&key)
.first_or_octet_stream()
.to_string(),
)
.header("X-Iroh-Hash", hash.to_string())
.body(Body::default())
.unwrap(),
Method::GET => Response::builder()
.header("Content-Length", file_size)
.header("Content-Type", mime_guess::from_ext(&key).first_or_octet_stream().to_string())
.header(
"Content-Type",
mime_guess::from_ext(&key)
.first_or_octet_stream()
.to_string(),
)
.header("X-Iroh-Hash", hash.to_string())
.body(Body::from_stream(ReaderStream::new(reader)))
.unwrap(),
Expand Down
6 changes: 3 additions & 3 deletions src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,13 @@ impl Table {
.await
.map_err(Error::entry)?;
if let Some(entry) = entry {
let is_complete = self
let db_entry = self
.node
.db()
.get(&entry.content_hash())
.await
.unwrap_or_default()
.map_or(false, |db_entry| db_entry.is_complete());
.unwrap_or_default();
let is_complete = db_entry.map_or(false, |db_entry| db_entry.is_complete());
if !is_complete {
if let Ok(Some(mut peers)) = self.iroh_doc.get_sync_peers().await {
peers.shuffle(&mut thread_rng());
Expand Down

0 comments on commit 7fb0b0e

Please sign in to comment.