Principle:0xsline OpenChatCut Export Destination Delivery
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Video_Export, File_System, Delivery |
| Last Updated | 2026-10-22 14:00 GMT |
Overview
Delivery principle that writes a rendered export file to a user-selected directory atomically via a temp-file-and-rename strategy, with size limits, lease-based concurrency control, and grant-based authorization.
Description
Export Destination Delivery is the final stage of the export pipeline. After rendering and QA, the export file must be written to a user-chosen directory. This principle ensures:
- Atomic writes: The file is written to a temp file (`.openchatcut-<uuid>.part`) then renamed to the final name, so a crash never leaves a partial file at the destination.
- Grant authorization: Only pre-authorized export directory grants can receive files; arbitrary paths are rejected.
- Path safety: The destination filename is sanitized and must resolve within the grant directory (no path traversal).
- Size limits: Maximum export size is 100 GB.
- Concurrency leases: A per-target lease prevents two simultaneous writes to the same file.
- Source flexibility: The file can be streamed from the PUT body or copied from an existing upload source via the `x-openchatcut-export-source` header.
- Empty-file rejection: A zero-byte result is rejected as an error.
Usage
Use this principle when:
- Writing export files to user-selected directories safely.
- Preventing partial writes from crashes during delivery.
- Authorizing only pre-approved destination directories.
- Supporting both streamed and source-copy delivery modes.
Theoretical Basis
The atomic-write pattern:
- Authorize: Resolve the grant ID and verify the destination directory exists.
- Sanitize: Validate the filename and resolve the target path within the grant directory.
- Lease: Acquire a per-target lease to prevent concurrent writes.
- Stage: Write to a temporary file in the same directory.
- Validate: Check the staged file is non-empty and within size limits.
- Commit: Atomically rename the temp file to the final name.
- Release: Release the lease and respond with 204 No Content.
Related Pages
Implemented By
Uses Heuristic
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment