1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:08:13 +00:00

LibSQL: Always read and write entire heap blocks

This commit is contained in:
Tim Schumacher 2023-03-01 17:30:30 +01:00 committed by Linus Groh
parent ba354fa396
commit 26516ee160

View file

@ -91,11 +91,9 @@ ErrorOr<ByteBuffer> Heap::read_block(u32 block)
TRY(seek_block(block));
auto buffer = TRY(ByteBuffer::create_uninitialized(BLOCKSIZE));
// FIXME: This should read the entire span.
auto bytes = TRY(m_file->read_some(buffer));
TRY(m_file->read_until_filled(buffer));
dbgln_if(SQL_DEBUG, "{:hex-dump}", bytes.trim(8));
TRY(buffer.try_resize(bytes.size()));
dbgln_if(SQL_DEBUG, "{:hex-dump}", buffer.bytes().trim(8));
return buffer;
}
@ -124,8 +122,7 @@ ErrorOr<void> Heap::write_block(u32 block, ByteBuffer& buffer)
}
dbgln_if(SQL_DEBUG, "{:hex-dump}", buffer.bytes().trim(8));
// FIXME: This should write the entire span.
TRY(m_file->write_some(buffer));
TRY(m_file->write_until_depleted(buffer));
if (block == m_end_of_file)
m_end_of_file++;