Skip to content

Commit 106fda9

Browse files
authored
chore(deps): bump object store crate (#16)
Signed-off-by: dark0dave <[email protected]>
1 parent 1a2f6bc commit 106fda9

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

object-store-internal/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ async-trait = "0.1.57"
1010
bytes = "1.2.1"
1111
futures = "0.3"
1212
once_cell = "1.12.0"
13-
object_store = { version = "0.9", features = ["azure", "aws", "gcp"] }
13+
object_store = { version = "0.10.1", features = ["azure", "aws", "gcp"] }
1414
percent-encoding = "2"
1515
pyo3 = { version = "0.20", default-features = false, features = ["macros"] }
1616
pyo3-asyncio = { version = "0.20", features = ["tokio-runtime"] }

object-store-internal/src/file.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ use crate::utils::{delete_dir, walk_tree};
66
use crate::{ObjectStoreError, PyClientOptions};
77

88
use object_store::path::Path;
9-
use object_store::{DynObjectStore, Error as InnerObjectStoreError, ListResult, MultipartId};
9+
use object_store::{DynObjectStore, Error as InnerObjectStoreError, ListResult, MultipartUpload};
1010
use pyo3::exceptions::{PyNotImplementedError, PyValueError};
1111
use pyo3::prelude::*;
1212
use pyo3::types::{IntoPyDict, PyBytes};
13-
use tokio::io::{AsyncWrite, AsyncWriteExt};
1413
use tokio::runtime::Runtime;
1514

1615
#[pyclass(subclass, weakref)]
@@ -442,11 +441,10 @@ impl ObjectInputFile {
442441
// TODO add buffer to store data ...
443442
#[pyclass(weakref)]
444443
pub struct ObjectOutputStream {
445-
store: Arc<DynObjectStore>,
444+
pub store: Arc<DynObjectStore>,
446445
rt: Arc<Runtime>,
447-
path: Path,
448-
writer: Box<dyn AsyncWrite + Send + Unpin>,
449-
multipart_id: MultipartId,
446+
pub path: Path,
447+
writer: Box<dyn MultipartUpload>,
450448
pos: i64,
451449
#[pyo3(get)]
452450
closed: bool,
@@ -460,17 +458,18 @@ impl ObjectOutputStream {
460458
store: Arc<DynObjectStore>,
461459
path: Path,
462460
) -> Result<Self, ObjectStoreError> {
463-
let (multipart_id, writer) = store.put_multipart(&path).await.unwrap();
464-
Ok(Self {
465-
store,
466-
rt,
467-
path,
468-
writer,
469-
multipart_id,
470-
pos: 0,
471-
closed: false,
472-
mode: "wb".into(),
473-
})
461+
match store.put_multipart(&path).await {
462+
Ok(writer) => Ok(Self {
463+
store,
464+
rt,
465+
path,
466+
writer,
467+
pos: 0,
468+
closed: false,
469+
mode: "wb".into(),
470+
}),
471+
Err(err) => Err(ObjectStoreError::ObjectStore(err)),
472+
}
474473
}
475474

476475
fn check_closed(&self) -> Result<(), ObjectStoreError> {
@@ -488,11 +487,11 @@ impl ObjectOutputStream {
488487
impl ObjectOutputStream {
489488
fn close(&mut self) -> PyResult<()> {
490489
self.closed = true;
491-
match self.rt.block_on(self.writer.shutdown()) {
490+
match self.rt.block_on(self.writer.complete()) {
492491
Ok(_) => Ok(()),
493492
Err(err) => {
494493
self.rt
495-
.block_on(self.store.abort_multipart(&self.path, &self.multipart_id))
494+
.block_on(self.writer.abort())
496495
.map_err(ObjectStoreError::from)?;
497496
Err(ObjectStoreError::from(err).into())
498497
}
@@ -537,24 +536,25 @@ impl ObjectOutputStream {
537536

538537
fn write(&mut self, data: &PyBytes) -> PyResult<i64> {
539538
self.check_closed()?;
540-
let len = data.as_bytes().len() as i64;
541-
match self.rt.block_on(self.writer.write_all(data.as_bytes())) {
539+
let bytes = data.as_bytes().to_vec();
540+
let len = bytes.len() as i64;
541+
match self.rt.block_on(self.writer.put_part(bytes.into())) {
542542
Ok(_) => Ok(len),
543543
Err(err) => {
544544
self.rt
545-
.block_on(self.store.abort_multipart(&self.path, &self.multipart_id))
545+
.block_on(self.writer.abort())
546546
.map_err(ObjectStoreError::from)?;
547547
Err(ObjectStoreError::from(err).into())
548548
}
549549
}
550550
}
551551

552552
fn flush(&mut self) -> PyResult<()> {
553-
match self.rt.block_on(self.writer.flush()) {
553+
match self.rt.block_on(self.writer.complete()) {
554554
Ok(_) => Ok(()),
555555
Err(err) => {
556556
self.rt
557-
.block_on(self.store.abort_multipart(&self.path, &self.multipart_id))
557+
.block_on(self.writer.abort())
558558
.map_err(ObjectStoreError::from)?;
559559
Err(ObjectStoreError::from(err).into())
560560
}

0 commit comments

Comments
 (0)