Add TOASTY_WRITE_TRUNCATE_AFTER flag for HTTP PUT semantics
Adds support for truncating files after write operations, enabling proper HTTP PUT semantics where the entire file content should be replaced. Implementation: - Added TOASTY_WRITE_TRUNCATE_AFTER flag (0x02) to ToastyFS API - Updated file_tree_write() to accept truncate_after parameter: * When true, sets file size to exactly offset+length * Removes chunks beyond the new file size * Marks removed chunks for garbage collection - Metadata server extracts and passes truncate flag to file_tree_write() - WAL replay passes false for truncate_after (already handled in original write) - Web proxy PUT now uses both CREATE_IF_MISSING and TRUNCATE_AFTER flags - Updated documentation in PROTOCOL.txt, DESIGN.txt, and web/DESIGN.txt Benefits: - Proper HTTP PUT semantics (replace entire file content) - Efficient: single write operation truncates and updates file - Works with both sync and async APIs - Garbage collection automatically removes orphaned chunks
This commit is contained in:
+7
-4
@@ -35,10 +35,13 @@ PUT
|
||||
operation fails with code 400.
|
||||
|
||||
If the path refers to a file, the file is automatically created if it
|
||||
doesn't exist, then the specified contents are written to it. This is
|
||||
implemented using the TOASTY_WRITE_CREATE_IF_MISSING flag which performs
|
||||
file creation and write atomically on the metadata server. Files are
|
||||
created with a default chunk size of 4096 bytes.
|
||||
doesn't exist, then the specified contents are written to it, replacing
|
||||
the entire file content (HTTP PUT semantics). This is implemented using
|
||||
two flags:
|
||||
- TOASTY_WRITE_CREATE_IF_MISSING: Creates file if it doesn't exist
|
||||
- TOASTY_WRITE_TRUNCATE_AFTER: Truncates file after the write, discarding
|
||||
any data beyond the uploaded content
|
||||
Files are created with a default chunk size of 4096 bytes.
|
||||
|
||||
If a file or directory already existed at that path, it is overwritten
|
||||
unless the header "X-ToastyFS-Overwrite: no" is sent.
|
||||
|
||||
Reference in New Issue
Block a user