diff --git a/docs/todo.md b/docs/todo.md index 77e2d95..48cdf26 100644 --- a/docs/todo.md +++ b/docs/todo.md @@ -2,4 +2,5 @@ - [ ] Simple auth - [ ] postgresql - [ ] prometheus metrics -- [ ] streaming layer bytes into providers \ No newline at end of file +- [x] streaming layer bytes into providers +- [x] streaming layer bytes from providers \ No newline at end of file diff --git a/src/api/uploads.rs b/src/api/uploads.rs index 0cd5c06..97c4b30 100644 --- a/src/api/uploads.rs +++ b/src/api/uploads.rs @@ -28,7 +28,7 @@ pub async fn start_upload(path: web::Path<(String, )>) -> HttpResponse { } #[patch("/{uuid}")] -pub async fn chunked_upload_layer(/* body: Bytes */mut payload: web::Payload, path: web::Path<(String, String)>, req: HttpRequest, state: web::Data) -> HttpResponse { +pub async fn chunked_upload_layer(mut payload: web::Payload, path: web::Path<(String, String)>, req: HttpRequest, state: web::Data) -> HttpResponse { let full_uri = req.uri().to_string(); let (_name, layer_uuid) = (path.0.to_owned(), path.1.to_owned()); diff --git a/src/storage/filesystem.rs b/src/storage/filesystem.rs index e554c8c..0987add 100644 --- a/src/storage/filesystem.rs +++ b/src/storage/filesystem.rs @@ -104,32 +104,10 @@ impl FilesystemDriver { } impl StorageDriverStreamer for FilesystemDriver { - fn write_payload(&self, digest: &str, payload: actix_web::web::Payload, append: bool) -> anyhow::Result { - Ok(tokio::runtime::Handle::current() - .block_on(self.write_payload(digest, payload, append))?) - - /* block_on(|| async { - let path = self.get_digest_path(digest); - let mut file = fs::OpenOptions::new() - .write(true) - .append(append) - .create(true) - .open(path).await?; - - file.write_all(&bytes).await?; - - Ok(()) - }); */ - } - fn supports_streaming(&self) -> bool { true } - fn start_streaming_thread(&self) -> anyhow::Result<()> { - todo!() - } - fn start_stream_channel(&self) -> mpsc::Sender<(String, Bytes)> { self.streamer_sender.clone() } diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 8084366..b4588e2 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -14,12 +14,7 @@ pub trait Streamer { } pub trait StorageDriverStreamer { - /// Write an actix-web payload into the StorageDriver - /// Returns the amount of bytes written - fn write_payload(&self, digest: &str, payload: actix_web::web::Payload, append: bool) -> anyhow::Result; - fn supports_streaming(&self) -> bool; - fn start_streaming_thread(&self) -> anyhow::Result<()>; fn start_stream_channel(&self) -> mpsc::Sender<(String, Bytes)>; } @@ -31,7 +26,4 @@ pub trait StorageDriver: Send + StorageDriverStreamer/* : AsyncWrite + AsyncRead async fn save_digest(&self, digest: &str, bytes: &Bytes, append: bool) -> anyhow::Result<()>; async fn delete_digest(&self, digest: &str) -> anyhow::Result<()>; async fn replace_digest(&self, uuid: &str, digest: &str) -> anyhow::Result<()>; - - //async fn write_payload(&self, payload: Mutex) -> anyhow::Result<()>; - //async fn write_stream>(&self, stream: S) -> anyhow::Result<()>; } \ No newline at end of file