Documentation
¶
Overview ¶
Package artifact owns generated media, output paths, persistence, and cleanup.
Index ¶
Constants ¶
const (
ResponseEmptyInline = "empty inline result"
)
The internal/artifact section of the copy catalog, one constant per entry.
const SidecarExt = ".md"
SidecarExt is the Markdown extension shared by sidecar persistence and collision checks.
Variables ¶
This section is empty.
Functions ¶
func Cleanup ¶
Cleanup attempts to remove every temporary source in the supplied artifacts. It clears their TmpPath fields even on failure and returns all removal errors.
func CreateDir ¶
CreateDir creates a directory and missing parents, accepting an existing directory.
func DefaultStem ¶
DefaultStem returns the default filename stem for an image or video run.
func ExpandHome ¶
ExpandHome replaces ~, or a leading ~ followed by a slash or the platform's separator, with the home directory, returning an error if it is unavailable. Other paths are unchanged.
Types ¶
type Location ¶
Location contains the parsed components of an output path.
- Dir: the directory portion of the path
- Stem: the filename without its extension
- Ext: the supported media extension as supplied
- Format: the image format represented by Ext
func ParseOutPath ¶
ParseOutPath separates an output path into its directory, stem, and supported media extension. Unsupported extensions are discarded; only image extensions select an output format.
type Media ¶
Media contains generated media stored in memory or in a temporary file.
- Data: the generated bytes when held in memory
- TmpPath: the temporary file path when stored on disk
- FileExt: the detected or fallback filename extension, including its leading period
type SavedFile ¶
SavedFile describes a successfully closed output file.
- Path: the saved destination path
- Bytes: the number of bytes written
func WriteMedia ¶
func WriteMedia(dir, requestedStem string, mediaKind media.Kind, artifacts []Media, writesSidecar bool) (finalStem string, completedFiles []SavedFile, writeErr error)
WriteMedia saves generated media under an available stem and returns all completed files. A destination failure stops further writes. It then attempts source cleanup for every supplied artifact, clearing each TmpPath even when removal fails.