Skip to content

Handle non-sequential writes in MultiuserFile#61

Open
djw8605 wants to merge 1 commit intomasterfrom
allow-non-sequential-write
Open

Handle non-sequential writes in MultiuserFile#61
djw8605 wants to merge 1 commit intomasterfrom
allow-non-sequential-write

Conversation

@djw8605
Copy link
Member

@djw8605 djw8605 commented Feb 13, 2026

Disable checksum calculation for non-sequential writes and update the offset correctly after writing.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates MultiuserFile::Write to tolerate non-sequential writes by disabling on-write checksum calculation instead of rejecting the write, and it corrects how the next expected write offset is tracked.

Changes:

  • Disable checksum calculation when a non-sequential write is detected (instead of returning -ENOTSUP).
  • Update m_nextoff to offset + bytes_written after each successful write.
Comments suppressed due to low confidence (1)

src/multiuser.cpp:191

  • Checksum updates use the requested size instead of the actual number of bytes written (result). If the underlying write is partial, the checksum state (and its internal offset) will advance too far and the final checksum will not match the file contents. Update the checksum with exactly the bytes successfully written (and only when result > 0).
    auto result = m_wrapped->Write(buffer, offset, size);
    if (result >= 0) {m_nextoff = offset + result;}
    if (m_state)
    {
        m_state->Update(static_cast<const unsigned char*>(buffer), size);
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant