filemanager

package
v0.0.0-...-1618023 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCannotImport is returned whenever we are told to reload but cannot due to missing import_directory
	ErrCannotImport = errors.New("filemanager: cannot import because import_directory is not set in the config")
	// SystemUserUUID is the UUID of files uploaded by the GoCrack system
	SystemUserUUID = "b2c9e661-74e5-4ba3-b1ce-624894e85622"
)

Functions

This section is empty.

Types

type Config

type Config struct {
	TaskUploadPath string  `yaml:"task_file_path"`
	EngineFilePath string  `yaml:"engine_file_path"`
	TempPath       string  `yaml:"temp_path"`
	TaskMaxSize    *int    `yaml:"task_max_upload_size,omitempty"`
	ImportPath     *string `yaml:"import_path,omitempty"`
}

Config describes the settings available to GoCrack's filemanager

func (*Config) Validate

func (s *Config) Validate() error

Validate the FileManager config by ensuring the directories exist

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context contains the state of the filemanager and provides public methods to interact with all filesystem actions within gocrack

func New

func New(stor FileManagerStor, cfg Config) *Context

New creates a new FileManager for GoCrack

func (*Context) DeleteFile

func (s *Context) DeleteFile(doc interface{}) error

DeleteFile removes the file from the system

func (*Context) Refresh

func (s *Context) Refresh() error

Refresh checks the import directory for new files and saves them into the database

func (*Context) SaveFile

func (s *Context) SaveFile(src io.ReadCloser, filename string, fileUUID string, filetype interface{}) (*FileSaveResponse, error)

SaveFile returns metadata about the file and saves the file to disk

type FileManagerStor

type FileManagerStor interface {
	NewEngineFileTransaction() (storage.EngineFileTxn, error)
	DeleteEngineFile(string) error
	DeleteTaskFile(string) error
}

type FileSaveResponse

type FileSaveResponse struct {
	Size          int64
	SavedTo       string
	NumberOfLines int64
	SHA1          string
}

type WriteSizeLineRecorder

type WriteSizeLineRecorder struct {
	// contains filtered or unexported fields
}

WriteSizeLineRecorder records the total size of a write and includes the # of lines

func (WriteSizeLineRecorder) Lines

func (w WriteSizeLineRecorder) Lines() int64

Lines returns the total number of new lines detected

func (WriteSizeLineRecorder) Size

func (w WriteSizeLineRecorder) Size() int64

Size indicates the total size written to this recorder

func (*WriteSizeLineRecorder) Write

func (w *WriteSizeLineRecorder) Write(p []byte) (n int, err error)

type WriteSizeRecorder

type WriteSizeRecorder struct {
	// contains filtered or unexported fields
}

WriteSizeRecorder records the total size of a write (helpful in a multiwriter)

func (WriteSizeRecorder) Size

func (w WriteSizeRecorder) Size() int64

Size indicates the total size written to this recorder

func (*WriteSizeRecorder) Write

func (w *WriteSizeRecorder) Write(p []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL