Fix truncate impl in JS bindings

This commit is contained in:
PThorpe92
2025-07-17 23:26:07 -04:00
committed by Jussi Saurio
parent 3be8bb374d
commit 272a63b562
3 changed files with 14 additions and 6 deletions

View File

@@ -726,6 +726,10 @@ impl turso_core::DatabaseStorage for DatabaseFile {
fn size(&self) -> turso_core::Result<u64> {
self.file.size()
}
fn truncate(&self, len: usize, c: turso_core::Completion) -> turso_core::Result<()> {
let _ = self.file.truncate(len, c)?;
Ok(())
}
}
#[inline]

View File

@@ -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<Arc<turso_core::Completion>> {
fn truncate(
&self,
len: usize,
c: turso_core::Completion,
) -> Result<Arc<turso_core::Completion>> {
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(())
}
}

View File

@@ -18,7 +18,7 @@ pub trait DatabaseStorage: Send + Sync {
) -> Result<Completion>;
fn sync(&self, c: Completion) -> Result<Completion>;
fn size(&self) -> Result<u64>;
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(())
}