Skip to content

Commit d24fde0

Browse files
committed
fix(bindings): resolve additional
CI compilation errors - C bindings: Calculate milliseconds from Timestamp using as_second() and subsec_nanosecond() - Python bindings: Change Timestamp to String for PyO3 compatibility - dav-server integration: Use as_system_time() for Timestamp to SystemTime conversion
1 parent 0de9fea commit d24fde0

4 files changed

Lines changed: 16 additions & 17 deletions

File tree

bindings/c/src/metadata.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ impl opendal_metadata {
132132
match mtime {
133133
None => -1,
134134
Some(time) => {
135-
let jiff_ts: jiff::Timestamp = time.into_inner();
136-
jiff_ts.as_millisecond()
135+
time.as_second() * 1000 + (time.subsec_nanosecond() / 1_000_000) as i64
137136
}
138137
}
139138
}

bindings/python/src/metadata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ impl Metadata {
121121

122122
/// Last modified time
123123
#[getter]
124-
pub fn last_modified(&self) -> Option<Timestamp> {
125-
self.0.last_modified()
124+
pub fn last_modified(&self) -> Option<String> {
125+
self.0.last_modified().map(|t| t.to_string())
126126
}
127127

128128
/// Version of this entry, if available.

bindings/python/src/options.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// under the License.
1717

1818
use dict_derive::FromPyObject;
19-
use opendal::{self as ocore, raw::BytesRange, raw::Timestamp};
19+
use opendal::{self as ocore, raw::BytesRange};
2020
use pyo3::pyclass;
2121
use std::collections::HashMap;
2222

@@ -32,8 +32,8 @@ pub struct ReadOptions {
3232
pub size: Option<usize>,
3333
pub if_match: Option<String>,
3434
pub if_none_match: Option<String>,
35-
pub if_modified_since: Option<Timestamp>,
36-
pub if_unmodified_since: Option<Timestamp>,
35+
pub if_modified_since: Option<String>,
36+
pub if_unmodified_since: Option<String>,
3737
pub content_type: Option<String>,
3838
pub cache_control: Option<String>,
3939
pub content_disposition: Option<String>,
@@ -71,8 +71,8 @@ impl From<ReadOptions> for ocore::options::ReadOptions {
7171
version: opts.version,
7272
if_match: opts.if_match,
7373
if_none_match: opts.if_none_match,
74-
if_modified_since: opts.if_modified_since,
75-
if_unmodified_since: opts.if_unmodified_since,
74+
if_modified_since: opts.if_modified_since.and_then(|s| s.parse().ok()),
75+
if_unmodified_since: opts.if_unmodified_since.and_then(|s| s.parse().ok()),
7676
concurrent: opts.concurrent.unwrap_or_default(),
7777
chunk: opts.chunk,
7878
gap: opts.gap,
@@ -89,8 +89,8 @@ impl From<ReadOptions> for ocore::options::ReaderOptions {
8989
version: opts.version,
9090
if_match: opts.if_match,
9191
if_none_match: opts.if_none_match,
92-
if_modified_since: opts.if_modified_since,
93-
if_unmodified_since: opts.if_unmodified_since,
92+
if_modified_since: opts.if_modified_since.and_then(|s| s.parse().ok()),
93+
if_unmodified_since: opts.if_unmodified_since.and_then(|s| s.parse().ok()),
9494
concurrent: opts.concurrent.unwrap_or_default(),
9595
chunk: opts.chunk,
9696
gap: opts.gap,
@@ -145,8 +145,8 @@ pub struct StatOptions {
145145
pub version: Option<String>,
146146
pub if_match: Option<String>,
147147
pub if_none_match: Option<String>,
148-
pub if_modified_since: Option<Timestamp>,
149-
pub if_unmodified_since: Option<Timestamp>,
148+
pub if_modified_since: Option<String>,
149+
pub if_unmodified_since: Option<String>,
150150
pub content_type: Option<String>,
151151
pub cache_control: Option<String>,
152152
pub content_disposition: Option<String>,
@@ -158,8 +158,8 @@ impl From<StatOptions> for ocore::options::StatOptions {
158158
version: opts.version,
159159
if_match: opts.if_match,
160160
if_none_match: opts.if_none_match,
161-
if_modified_since: opts.if_modified_since,
162-
if_unmodified_since: opts.if_unmodified_since,
161+
if_modified_since: opts.if_modified_since.and_then(|s| s.parse().ok()),
162+
if_unmodified_since: opts.if_unmodified_since.and_then(|s| s.parse().ok()),
163163
override_content_type: opts.content_type,
164164
override_cache_control: opts.cache_control,
165165
override_content_disposition: opts.content_disposition,

integrations/dav-server/src/metadata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl DavMetaData for OpendalMetaData {
4040

4141
fn modified(&self) -> FsResult<SystemTime> {
4242
match self.metadata.last_modified() {
43-
Some(t) => Ok(t.into()),
43+
Some(t) => Ok(t.as_system_time()),
4444
None => Err(FsError::GeneralFailure),
4545
}
4646
}
@@ -60,6 +60,6 @@ impl DavMetaData for OpendalMetaData {
6060
fn status_changed(&self) -> FsResult<SystemTime> {
6161
self.metadata
6262
.last_modified()
63-
.map_or(Err(FsError::GeneralFailure), |t| Ok(t.into()))
63+
.map_or(Err(FsError::GeneralFailure), |t| Ok(t.as_system_time()))
6464
}
6565
}

0 commit comments

Comments
 (0)