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) Usage() (int64, error)
- type ZipResult
Constants ¶
This section is empty.
Variables ¶
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 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 ¶
Plan is the resolved list of files, shown to the user before anything is sent.
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.
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.