Documentation
¶
Overview ¶
Package volumefiles browses and edits single files inside a named volume's host directory, confined to that directory by os.Root so traversal and symlink escapes fail in the kernel-facing layer rather than by string checks.
Index ¶
- Variables
- func Classify(err error) error
- func Clean(p string) (string, error)
- func EffectiveLimit(requested int) int
- func EffectiveMax(requested int64) int64
- func EncodeEntries(w io.Writer, entries []Entry, truncated bool) error
- func ListLimit() int
- func MaxUploadBytes() int64
- type Entry
- type Store
- func (s *Store) Close() error
- func (s *Store) List(p string, limit int) ([]Entry, bool, error)
- func (s *Store) Read(p string) (io.ReadCloser, int64, error)
- func (s *Store) Remove(p string) error
- func (s *Store) Write(p string, r io.Reader, maxBytes int64) (int64, error)
- func (s *Store) WriteMode(p string, r io.Reader, maxBytes int64, want fs.FileMode) (int64, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPathEscapes is returned for any path that leaves the volume root. ErrPathEscapes = errors.New("volumefiles: path escapes the volume") // ErrNotFound means the path does not exist inside the volume. ErrNotFound = errors.New("volumefiles: no such file") // ErrIsDirectory means a file operation was aimed at a directory. ErrIsDirectory = errors.New("volumefiles: path is a directory") // ErrNotRegular means the path is a device, socket, fifo or similar. ErrNotRegular = errors.New("volumefiles: path is not a regular file") // ErrTooLarge means an upload exceeded the configured cap. ErrTooLarge = errors.New("volumefiles: upload exceeds the size limit") )
Functions ¶
func Clean ¶
Clean maps a user path to a slash-separated path relative to the volume root, rejecting NUL bytes and any ".." component. "" and "/" mean the root.
func EffectiveLimit ¶
EffectiveLimit returns the smaller positive of requested and the env cap.
func EffectiveMax ¶
EffectiveMax returns the smaller positive of requested and the env cap.
func EncodeEntries ¶
EncodeEntries writes entries as JSON lines, plus a final truncated marker.
func ListLimit ¶
func ListLimit() int
ListLimit is the per-directory entry cap from APP_VOLUME_FILE_LIST_LIMIT.
func MaxUploadBytes ¶
func MaxUploadBytes() int64
MaxUploadBytes is the per-file upload cap from APP_VOLUME_FILE_MAX_UPLOAD_MB.
Types ¶
type Entry ¶
type Entry struct {
Name string `json:"name"`
Path string `json:"path"`
Type string `json:"type"`
Size int64 `json:"size"`
Mode string `json:"mode"`
ModTime string `json:"mod_time"`
Truncated bool `json:"truncated,omitempty"`
}
Entry is one item in a directory listing.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store performs file operations strictly inside one volume directory.
func (*Store) List ¶
List returns up to limit entries of the directory at p, directories first, and whether more existed. Symlinks are listed, never followed.
func (*Store) Remove ¶
Remove deletes exactly one non-directory entry; a symlink is removed, not followed.