From 272a63b56246deeab3cfd98461208c386dd6149f Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Thu, 17 Jul 2025 23:26:07 -0400 Subject: [PATCH] Fix truncate impl in JS bindings --- bindings/javascript/src/lib.rs | 4 ++++ bindings/wasm/lib.rs | 10 +++++++--- core/storage/database.rs | 6 +++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bindings/javascript/src/lib.rs b/bindings/javascript/src/lib.rs index 45ce3b958..2c9f874ef 100644 --- a/bindings/javascript/src/lib.rs +++ b/bindings/javascript/src/lib.rs @@ -726,6 +726,10 @@ impl turso_core::DatabaseStorage for DatabaseFile { fn size(&self) -> turso_core::Result { self.file.size() } + fn truncate(&self, len: usize, c: turso_core::Completion) -> turso_core::Result<()> { + let _ = self.file.truncate(len, c)?; + Ok(()) + } } #[inline] diff --git a/bindings/wasm/lib.rs b/bindings/wasm/lib.rs index 23ddebf68..40bafe9b5 100644 --- a/bindings/wasm/lib.rs +++ b/bindings/wasm/lib.rs @@ -261,7 +261,11 @@ impl turso_core::File for File { Ok(self.vfs.size(self.fd)) } - fn truncate(&self, len: u64, c: turso_core::Completion) -> Result> { + fn truncate( + &self, + len: usize, + c: turso_core::Completion, + ) -> Result> { self.vfs.truncate(self.fd, len as usize); c.complete(0); #[allow(clippy::arc_with_non_send_sync)] @@ -387,8 +391,8 @@ impl turso_core::DatabaseStorage for DatabaseFile { self.file.size() } - fn truncate(&self, len: u64, c: turso_core::Completion) -> Result<()> { - self.file.truncate(len, c); + fn truncate(&self, len: usize, c: turso_core::Completion) -> Result<()> { + self.file.truncate(len, c)?; Ok(()) } } diff --git a/core/storage/database.rs b/core/storage/database.rs index 422663027..17f17439b 100644 --- a/core/storage/database.rs +++ b/core/storage/database.rs @@ -18,7 +18,7 @@ pub trait DatabaseStorage: Send + Sync { ) -> Result; fn sync(&self, c: Completion) -> Result; fn size(&self) -> Result; - fn truncate(&self, len: u64, c: Completion) -> Result<()>; + fn truncate(&self, len: usize, c: Completion) -> Result<()>; } #[cfg(feature = "fs")] @@ -72,7 +72,7 @@ impl DatabaseStorage for DatabaseFile { } #[instrument(skip_all, level = Level::INFO)] - fn truncate(&self, len: u64, c: Completion) -> Result<()> { + fn truncate(&self, len: usize, c: Completion) -> Result<()> { self.file.truncate(len, c)?; Ok(()) } @@ -131,7 +131,7 @@ impl DatabaseStorage for FileMemoryStorage { } #[instrument(skip_all, level = Level::INFO)] - fn truncate(&self, len: u64, c: Completion) -> Result<()> { + fn truncate(&self, len: usize, c: Completion) -> Result<()> { let _ = self.file.truncate(len, c)?; Ok(()) }