You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by er...@apache.org on 2026/07/04 09:18:20 UTC
(opendal) branch fix-sqlite-stat created (now 6ddb38ba5)
This is an automated email from the ASF dual-hosted git repository.
erickguan pushed a change to branch fix-sqlite-stat
in repository https://gitbox.apache.org/repos/asf/opendal.git
at 6ddb38ba5 Fix sqlite stat getting the entire object
This branch includes the following new commits:
new 6ddb38ba5 Fix sqlite stat getting the entire object
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(opendal) 01/01: Fix sqlite stat getting the entire object
Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
erickguan pushed a commit to branch fix-sqlite-stat
in repository https://gitbox.apache.org/repos/asf/opendal.git
commit 6ddb38ba57f06a6badf9170e469ef8310ba93922
Author: Erick Guan <29...@users.noreply.github.com>
AuthorDate: Sat Jul 4 17:18:01 2026 +0800
Fix sqlite stat getting the entire object
---
core/services/sqlite/src/backend.rs | 37 +++++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/core/services/sqlite/src/backend.rs b/core/services/sqlite/src/backend.rs
index 63feabbac..94449034a 100644
--- a/core/services/sqlite/src/backend.rs
+++ b/core/services/sqlite/src/backend.rs
@@ -228,10 +228,10 @@ impl Service for SqliteBackend {
if p == build_abs_path(&self.root, "") {
Ok(RpStat::new(Metadata::new(EntryMode::DIR)))
} else {
- let bs = self.core.get(&p).await?;
- match bs {
- Some(bs) => Ok(RpStat::new(
- Metadata::new(EntryMode::from_path(&p)).with_content_length(bs.len() as u64),
+ let length = self.core.get_length(&p).await?;
+ match length {
+ Some(length) => Ok(RpStat::new(
+ Metadata::new(EntryMode::from_path(&p)).with_content_length(length as u64),
)),
None => {
// Check if this might be a directory by looking for keys with this prefix
@@ -437,4 +437,33 @@ mod test {
assert_eq!(buffer.to_vec(), b"world");
}
+
+ #[tokio::test]
+ async fn test_sqlite_stat_uses_value_length() {
+ let core = SqliteCore {
+ pool: build_client().await,
+ config: Default::default(),
+ table: "test".to_string(),
+ key_field: "key".to_string(),
+ value_field: "value".to_string(),
+ };
+ let pool = core.get_client().await.unwrap();
+ sqlx::query("CREATE TABLE test (key TEXT PRIMARY KEY, value BLOB)")
+ .execute(pool)
+ .await
+ .unwrap();
+
+ let accessor = SqliteBackend::new(core);
+ let ctx = OperationContext::new();
+ let mut writer = accessor.write(&ctx, "hello", OpWrite::default()).unwrap();
+ writer.write(Buffer::from("hello world")).await.unwrap();
+ writer.close().await.unwrap();
+
+ let rp = accessor
+ .stat(&ctx, "hello", OpStat::default())
+ .await
+ .unwrap();
+
+ assert_eq!(rp.into_metadata().content_length(), 11);
+ }
}