Commit Graph
7 Commits
Author SHA1 Message Date
cozis 49cee347f5 Add the terminator "/" to directory names when returning directory listings from the web interface 2025-12-05 09:19:25 +01:00
cozis 1e2223aeb0 Fix bad usage of the toastyfs client API in the web interface GET handler 2025-12-05 09:10:25 +01:00
Claude 4bcee9a617 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
2025-12-03 19:49:48 +00:00
Claude 8160c5ac51 Add TOASTY_WRITE_CREATE_IF_MISSING flag for server-side file auto-creation
Adds support for automatically creating files when write operations target
non-existent files. This is essential for REST PUT operations which should
be able to create new resources.

Implementation:
- Added TOASTY_WRITE_CREATE_IF_MISSING flag to ToastyFS API header
- Updated toasty_write() and toasty_begin_write() to accept flags parameter
- Client sends write flags in MESSAGE_TYPE_WRITE message to metadata server
- Metadata server parses flags and handles file auto-creation atomically:
  * When write fails with FILETREE_NOENT and flag is set
  * Logs creation to WAL for crash consistency
  * Creates file with default 4096-byte chunk size
  * Retries write with newly created file's generation tag
- Updated web proxy PUT handler to use TOASTY_WRITE_CREATE_IF_MISSING
- Updated examples and simulation client for new API signature

Benefits:
- Works for both sync and async APIs
- Single round trip (atomic server-side operation)
- Prevents race conditions
- Proper WAL logging ensures crash consistency
2025-12-03 18:48:42 +00:00
cozis 6519b0c1bb Fix incorrect call to http_response_builder_body_cap in toastyfs_web 2025-12-03 18:01:39 +01:00
cozis 012b31df3a Fix compilation warnings 2025-12-03 00:03:44 +01:00
cozis b0b2d576cc Refactoring of toastyfs_web 2025-12-03 00:03:36 +01:00