Documentation
¶
Overview ¶
Package sourceupload packs a local directory into a deterministic archive, stores uploaded archives for a bounded time and extracts them safely.
Index ¶
- Variables
- func ValidHash(s string) bool
- type File
- type Limits
- type Meta
- type Options
- type Plan
- type Stats
- type Store
- func (s *Store) Cleanup(retention time.Duration) (int, error)
- func (s *Store) Extract(app, hash, dest string) (Stats, error)
- func (s *Store) Get(app, hash string) (Meta, error)
- func (s *Store) List(app string) ([]Meta, error)
- func (s *Store) Open(app, hash string) (*os.File, error)
- func (s *Store) Put(app string, r io.Reader, maxBytes int64) (meta Meta, deduped bool, err error)
- func (s *Store) RemoveApp(app string) error
- func (s *Store) Usage() (int64, error)
- type ZipResult
Constants ¶
This section is empty.
Variables ¶
var ( EditorConfigFiles = []string{".DS_Store", "Thumbs.db"} EditorConfigGlobs = []string{"*.local.json", "*.local.yaml", "*.local.yml", "settings.local.*"} )
EditorConfigFiles are file names, and EditorConfigGlobs base name patterns, that are machine-local and never needed by a build.
var DefaultIgnores = []string{
".git", ".svn", ".hg", "node_modules", ".next", ".nuxt", ".turbo", ".venv", "venv",
"__pycache__", "target", "coverage", ".terraform", ".DS_Store",
".env", ".env.*", "*.pem", "*.key", "id_rsa*", "id_ed25519*",
}
DefaultIgnores are never uploaded unless named in Options.Include. Secrets and dependency or cache directories stay on the laptop by default.
var EditorConfigDirs = []string{".claude", ".cursor", ".windsurf", ".codex", ".idea", ".fleet", ".history"}
EditorConfigDirs are directory names holding personal editor or agent settings. Files below them are skipped unless named in Options.Include.
var ErrEmptyArchive = errors.New("sourceupload: archive has no files")
ErrEmptyArchive is returned when a zip holds no files once OS metadata is ignored.
var ErrInvalidName = errors.New("sourceupload: invalid app name or hash")
ErrInvalidName is returned for an app name or hash that is not a safe path segment.
var ErrNotFound = errors.New("sourceupload: upload not found")
ErrNotFound is returned when an upload is unknown or already expired.
var ErrTooLarge = errors.New("sourceupload: source exceeds the size limit")
ErrTooLarge is returned when a directory or archive exceeds its size cap.
var ErrUnsafeArchive = errors.New("sourceupload: unsafe archive entry")
ErrUnsafeArchive is returned for an entry that could escape the extraction root or is not a plain file.
Functions ¶
Types ¶
type Meta ¶
type Meta struct {
Hash string `json:"hash"`
App string `json:"app"`
Size int64 `json:"size"`
Files int `json:"file_count"`
Expanded int64 `json:"extracted_bytes"`
CreatedAt time.Time `json:"created_at"`
}
Meta describes one stored upload.
type Options ¶
type Options struct {
// Include re-adds paths the default and .gitignore rules would exclude, for example ".env".
Include []string
// MaxBytes caps the total uncompressed size of the files; 0 means no cap.
MaxBytes int64
}
Options tune Pack.
type Plan ¶
type Plan struct {
Root string
Files []File
Total int64
// EditorSkipped lists files left out as editor or agent config.
EditorSkipped []string
}
Plan is the resolved list of files, shown to the user before anything is sent.
func (Plan) EditorSkippedSummary ¶
EditorSkippedSummary returns the skipped count and up to limit file paths, so the message names real files rather than a misleading top directory.
type Stats ¶
Stats describes an archive's contents.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store keeps archives as <root>/<app>/<hash>.tar.gz with a .json sidecar.
func (*Store) Cleanup ¶
Cleanup removes uploads last stored or re-sent more than retention ago, plus abandoned partial files, and returns how many uploads it removed.
func (*Store) Put ¶
Put streams r into the store, enforcing maxBytes on the compressed size and validating the archive before it becomes visible. deduped is true when the same content already existed for the app.
type ZipResult ¶
type ZipResult struct {
Stats
// HasIndex reports whether index.html sits at the site root after wrapper folders are stripped.
HasIndex bool
// StrippedDir is the wrapper folder path removed so the site root is the archive root.
StrippedDir string
}
ZipResult describes a converted zip.