Skip to content

feat(wopi): report the file's SHA-256 in CheckFileInfo - #6055

Open
timar wants to merge 1 commit into
mainfrom
feat/checkfileinfo-sha256
Open

feat(wopi): report the file's SHA-256 in CheckFileInfo#6055
timar wants to merge 1 commit into
mainfrom
feat/checkfileinfo-sha256

Conversation

@timar

@timar timar commented Sep 8, 2026

Copy link
Copy Markdown
Member

After an upload that gets no answer, the editor has to work out whether what is in storage is what it just sent. Without a hash to compare it falls back on the byte count, which cannot tell our own document from another editor's of the same length: the wrong answer either loses the other writer's work or puts a needless conflict in front of the user.

Report the file's SHA-256 in the CheckFileInfo SHA256 field so there is something better to compare. The field is only present when a hash is on record; CheckFileInfo is on the document-open path and must not read a whole file to compute one.

For it to be on record when it matters, hash the body of PutFile as it streams past and store the result, the way the DAV endpoint stores the checksums a sync client sends. Wrapping the stream costs no extra read, since the bytes pass through us in any case. The scanner clears the checksum whenever a file changes, so what we hand out is never stale: it either describes the current contents or is absent, and setting it after putContent() keeps it that way.

Files written by other means, or before this change, simply carry no SHA-256 and the editor falls back as it does today.

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Documentation (manuals or wiki) has been updated or is not required

After an upload that gets no answer, the editor has to work out whether
what is in storage is what it just sent. Without a hash to compare it
falls back on the byte count, which cannot tell our own document from
another editor's of the same length: the wrong answer either loses the
other writer's work or puts a needless conflict in front of the user.

Report the file's SHA-256 in the CheckFileInfo SHA256 field so there is
something better to compare. The field is only present when a hash is on
record; CheckFileInfo is on the document-open path and must not read a
whole file to compute one.

For it to be on record when it matters, hash the body of PutFile as it
streams past and store the result, the way the DAV endpoint stores the
checksums a sync client sends. Wrapping the stream costs no extra read,
since the bytes pass through us in any case. The scanner clears the
checksum whenever a file changes, so what we hand out is never stale: it
either describes the current contents or is absent, and setting it after
putContent() keeps it that way.

Files written by other means, or before this change, simply carry no
SHA-256 and the editor falls back as it does today.

Signed-off-by: Andras Timar <andras.timar@collabora.com>
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