Add file chunk streaming to archive and restore handlers
Implement the raw chunk streaming protocol in both directions on the server
side. After accepting an ArchiveRequest, the handler enters a chunk receive
loop (handle_archive_chunks) that reads 4-byte big-endian length prefixes
followed by that many bytes of data, appending each chunk to the project’s
archive file on disk via append-mode file I/O. A zero-length chunk
signals EOF. The total bytes received is logged for monitoring.
On the restore side, handle_restore_chunks reads the complete archive file
from disk through the storage layer, then streams it back to the client in
1 MiB chunks with the same 4-byte length-prefixed format, followed by a
zero-length EOF marker and a flush. This mirrors the client’s
restore_project method which reads chunks in the same format.
The dispatch function now chains the chunk streaming phase after the
initial request acceptance: ArchiveRequest dispatch calls
handle_archive_start followed by handle_archive_chunks, and
RestoreRequest calls handle_restore_start followed by
handle_restore_chunks. The ArchiveComplete and RestoreComplete messages
are received as framed messages after the chunk phase completes, handled
by the existing finish functions.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.