diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-04-23 18:19:07 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-04-23 18:19:07 +0200 |
commit | 5d85fd16f2625b6efb7ed70254a275237dfab1eb (patch) | |
tree | b0857a3b48baf7317417dba65e17e379240ca4a5 /aero-proto/src/dav | |
parent | 6de63055a239be05053424460d019cea8b8495a2 (diff) | |
download | aerogramme-5d85fd16f2625b6efb7ed70254a275237dfab1eb.tar.gz aerogramme-5d85fd16f2625b6efb7ed70254a275237dfab1eb.zip |
basic thunderbird event is working!
Diffstat (limited to 'aero-proto/src/dav')
-rw-r--r-- | aero-proto/src/dav/node.rs | 2 | ||||
-rw-r--r-- | aero-proto/src/dav/resource.rs | 32 |
2 files changed, 17 insertions, 17 deletions
diff --git a/aero-proto/src/dav/node.rs b/aero-proto/src/dav/node.rs index 00dabce..4d5dd1a 100644 --- a/aero-proto/src/dav/node.rs +++ b/aero-proto/src/dav/node.rs @@ -35,7 +35,7 @@ pub(crate) trait DavNode: Send { fn properties(&self, user: &ArcUser, prop: dav::PropName<All>) -> PropertyStream<'static>; //fn properties(&self, user: &ArcUser, prop: dav::PropName<All>) -> Vec<dav::AnyProperty<All>>; /// Put an element (create or update) - fn put<'a>(&'a self, policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, Result<Etag>>; + fn put<'a>(&'a self, policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, std::result::Result<Etag, std::io::Error>>; /// Content type of the element fn content_type(&self) -> &str; /// Get content diff --git a/aero-proto/src/dav/resource.rs b/aero-proto/src/dav/resource.rs index 7477ba9..cb63b71 100644 --- a/aero-proto/src/dav/resource.rs +++ b/aero-proto/src/dav/resource.rs @@ -67,8 +67,8 @@ impl DavNode for RootNode { }).boxed() } - fn put<'a>(&'a self, _policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, Result<Etag>> { - todo!() + fn put<'a>(&'a self, _policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, std::result::Result<Etag, std::io::Error>> { + futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported)).boxed() } fn content(&self) -> Content<'static> { @@ -143,8 +143,8 @@ impl DavNode for HomeNode { }).boxed() } - fn put<'a>(&'a self, _policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, Result<Etag>> { - todo!() + fn put<'a>(&'a self, _policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, std::result::Result<Etag, std::io::Error>> { + futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported)).boxed() } fn content(&self) -> Content<'static> { @@ -230,8 +230,8 @@ impl DavNode for CalendarListNode { }).boxed() } - fn put<'a>(&'a self, _policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, Result<Etag>> { - todo!() + fn put<'a>(&'a self, _policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, std::result::Result<Etag, std::io::Error>> { + futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported)).boxed() } fn content(&self) -> Content<'static> { @@ -333,8 +333,8 @@ impl DavNode for CalendarNode { }).boxed() } - fn put<'a>(&'a self, _policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, Result<Etag>> { - todo!() + fn put<'a>(&'a self, _policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, std::result::Result<Etag, std::io::Error>> { + futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported)).boxed() } fn content<'a>(&'a self) -> Content<'static> { @@ -412,12 +412,12 @@ impl DavNode for EventNode { }).boxed() } - fn put<'a>(&'a self, policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, Result<Etag>> { + fn put<'a>(&'a self, policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, std::result::Result<Etag, std::io::Error>> { async { - let existing_etag = self.etag().await?; + let existing_etag = self.etag().await.or(Err(std::io::Error::new(std::io::ErrorKind::Other, "Etag error")))?; match policy { - PutPolicy::CreateOnly => bail!("Already existing"), - PutPolicy::ReplaceEtag(etag) if etag != existing_etag.as_str() => bail!("Would overwrite something we don't know"), + PutPolicy::CreateOnly => return Err(std::io::Error::from(std::io::ErrorKind::AlreadyExists)), + PutPolicy::ReplaceEtag(etag) if etag != existing_etag.as_str() => return Err(std::io::Error::from(std::io::ErrorKind::AlreadyExists)), _ => () }; @@ -425,8 +425,8 @@ impl DavNode for EventNode { // so we load everything in memory let mut evt = Vec::new(); let mut reader = stream.into_async_read(); - reader.read_to_end(&mut evt).await.unwrap(); - let (_token, entry) = self.col.put(self.filename.as_str(), evt.as_ref()).await?; + reader.read_to_end(&mut evt).await.or(Err(std::io::Error::from(std::io::ErrorKind::BrokenPipe)))?; + let (_token, entry) = self.col.put(self.filename.as_str(), evt.as_ref()).await.or(Err(std::io::ErrorKind::Interrupted))?; Ok(entry.2) }.boxed() } @@ -480,7 +480,7 @@ impl DavNode for CreateEventNode { futures::stream::iter(vec![]).boxed() } - fn put<'a>(&'a self, _policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, Result<Etag>> { + fn put<'a>(&'a self, _policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, std::result::Result<Etag, std::io::Error>> { //@NOTE: policy might not be needed here: whatever we put, there is no known entries here async { @@ -488,7 +488,7 @@ impl DavNode for CreateEventNode { let mut evt = Vec::new(); let mut reader = stream.into_async_read(); reader.read_to_end(&mut evt).await.unwrap(); - let (_token, entry) = self.col.put(self.filename.as_str(), evt.as_ref()).await?; + let (_token, entry) = self.col.put(self.filename.as_str(), evt.as_ref()).await.or(Err(std::io::ErrorKind::Interrupted))?; Ok(entry.2) }.boxed() } |