Documentation ¶
Index ¶
- Variables
- func CleanupTestStore(store *Store)
- func LinkTestFileStore(cloneTo string)
- func TempFile(dir, pattern string) (f *os.File, err error)
- type FileStatus
- type Store
- func (s *Store) BasePath() string
- func (s *Store) MoveToStored(checksum string, filesize int64, uploadedFilePath string) error
- func (s *Store) MustStoreFileForTest(checksum string, filesize int64, contents []byte)
- func (s *Store) OpenForUpload(checksum string, filesize int64) (*os.File, error)
- func (s *Store) RemoveStoredFile(filePath string) error
- func (s *Store) RemoveUploadedFile(filePath string)
- func (s *Store) ResolveFile(checksum string, filesize int64, storedOnly StoredOnly) (path string, status FileStatus)
- func (s *Store) StoragePath() string
- type StoredOnly
Constants ¶
This section is empty.
Variables ¶
var ( ErrFileDoesNotExist = errors.New("file does not exist") ErrNotInUploading = errors.New("file not stored in 'uploading' storage") )
Predefined errors
Functions ¶
func CleanupTestStore ¶
func CleanupTestStore(store *Store)
CleanupTestStore deletes a store returned by CreateTestStore()
func LinkTestFileStore ¶
func LinkTestFileStore(cloneTo string)
LinkTestFileStore creates a copy of _test_file_store in a temporary directory. Panics if there are any errors.
func TempFile ¶
TempFile creates a new temporary file in the directory dir, opens the file for reading and writing, and returns the resulting *os.File. The filename is generated by taking pattern and adding a random string to the end. If pattern includes a "*", the random string replaces the last "*". If dir is the empty string, TempFile uses the default directory for temporary files (see os.TempDir). Multiple programs calling TempFile simultaneously will not choose the same file. The caller can use f.Name() to find the pathname of the file. It is the caller's responsibility to remove the file when no longer needed.
Types ¶
type FileStatus ¶
type FileStatus int
FileStatus represents the status of a file in the store.
const ( StatusNotSet FileStatus = iota StatusDoesNotExist StatusUploading StatusStored )
Valid statuses for files in the store.
func (FileStatus) String ¶
func (fs FileStatus) String() string
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store represents the default Shaman file store.
func CreateTestStore ¶
func CreateTestStore() *Store
CreateTestStore returns a Store that can be used for unit testing.
func (*Store) MoveToStored ¶
MoveToStored moves a file from 'uploading' to 'stored' storage. It is assumed that the checksum and filesize have been verified.
func (*Store) MustStoreFileForTest ¶
MustStoreFileForTest allows a unit test to store some file in the 'stored' storage bin. Any error will cause a panic.
func (*Store) OpenForUpload ¶
OpenForUpload returns a file pointer suitable to stream an uploaded file to.
func (*Store) RemoveStoredFile ¶
RemoveStoredFile removes a file from the 'stored' storage bin.
func (*Store) RemoveUploadedFile ¶
RemoveUploadedFile removes a file from the 'uploading' storage bin. Errors are ignored.
func (*Store) ResolveFile ¶
func (s *Store) ResolveFile(checksum string, filesize int64, storedOnly StoredOnly) (path string, status FileStatus)
ResolveFile checks the status of the file in the store.
func (*Store) StoragePath ¶
StoragePath returns the directory path of the 'stored' storage bin.
type StoredOnly ¶
type StoredOnly bool
StoredOnly indicates whether to resolve only 'stored' files or also 'uploading' or 'checking'.
const ( ResolveStoredOnly StoredOnly = true ResolveEverything StoredOnly = false )
For the ResolveFile() call. This is more explicit than just true/false values.