Documentation
¶
Overview ¶
Package clipboard provides the disk based clipboard implementation
Index ¶
- Constants
- Variables
- type Clipboard
- func (c *Clipboard) Allow() bool
- func (c *Clipboard) DeleteFile(id string) error
- func (c *Clipboard) Expire() error
- func (c *Clipboard) List() ([]*File, error)
- func (c *Clipboard) MakePipe(id string) error
- func (c *Clipboard) ReadFile(id string, w io.Writer) error
- func (c *Clipboard) Stat(id string) (*File, error)
- func (c *Clipboard) Stats() (*Stats, error)
- func (c *Clipboard) WriteFile(id string, meta *File, rc io.ReadCloser) error
- type File
- type Stats
Constants ¶
const ( // FileRegexPart defines the regex for a valid file ID. Note that this does not include start/end markers, // as they can be different depending on the use case. FileRegexPart = `(?i)([a-z0-9][-_.a-z0-9]{1,100})` )
Variables ¶
var ( // ErrBrokenPipe is returned when the target file is a pipe and the consumer prematurely interrupts reading ErrBrokenPipe = errors.New("broken pipe") // ErrInvalidFileID is returned in any method that deals with file ID input for reserved identifiers (ReadFile, WriteFile, ...) ErrInvalidFileID = errors.New("invalid file id") )
Functions ¶
This section is empty.
Types ¶
type Clipboard ¶
type Clipboard struct {
// contains filtered or unexported fields
}
Clipboard is responsible for storing files on the file system. In addition to storage, it also takes care of expiring files, and of limiting total clipboard size and count.
func (*Clipboard) Allow ¶
Allow increases the clipboard file counter and returns true if a new file may be added
func (*Clipboard) DeleteFile ¶
DeleteFile removes the file with the given ID from the clipboard, including its metadata file
func (*Clipboard) Expire ¶
Expire will use List to list all clipboard entries and delete the ones that have expired
func (*Clipboard) Stats ¶
Stats returns statistics about the current clipboard. It also updates the limiters with the current cumulative values.
func (*Clipboard) WriteFile ¶
WriteFile writes the entire content of rc to the clipboard entry as well as a metadata file. The method observes the per-file size limit as defined in the config, as well as the total clipboard size limit. If a limit is reached, it will return util.ErrLimitReached. When the target file is a FIFO pipe (see MakePipe) and the consumer prematurely interrupts reading, ErrBrokenPipe may be returned.