shardedfilestore

package
v0.0.0-...-b7b927a Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package shardedfilestore is a modified version of the tusd/filestore implementation. Splits file storage into subdirectories based on the hash prefix. based on https://github.com/tus/tusd/blob/966f1d51639d3405b630e4c94c0b1d76a0f7475c/filestore/filestore.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveWithDirs

func RemoveWithDirs(path string, basePath string) (err error)

RemoveWithDirs deletes the given path and its empty parent directories up to the given basePath

Types

type ShardedFileStore

type ShardedFileStore struct {
	BasePath          string // Relative or absolute path to store files in.
	PrefixShardLayers int    // Number of extra directory layers to prefix file paths with.
	DBConn            *db.DatabaseConnection
	// contains filtered or unexported fields
}

ShardedFileStore implements various tusd.DataStore-related interfaces. See the interfaces for more documentation about the different methods.

func New

func New(basePath string, prefixShardLayers int, dbConnection *db.DatabaseConnection, log *zerolog.Logger) *ShardedFileStore

New creates a new file based storage backend. The directory specified will be used as the only storage entry. This method does not check whether the path exists, use os.MkdirAll to ensure. In addition, a locking mechanism is provided.

func (*ShardedFileStore) Close

func (store *ShardedFileStore) Close() error

Close frees the database connection pool held within ShardedFileStore

func (*ShardedFileStore) ConcatUploads

func (store *ShardedFileStore) ConcatUploads(dest string, uploads []string) (err error)

func (*ShardedFileStore) FinishUpload

func (store *ShardedFileStore) FinishUpload(id string) error

FinishUpload deduplicates the upload by its cryptographic hash

func (*ShardedFileStore) GetInfo

func (store *ShardedFileStore) GetInfo(id string) (tusd.FileInfo, error)

func (*ShardedFileStore) GetReader

func (store *ShardedFileStore) GetReader(id string) (io.Reader, error)

func (*ShardedFileStore) LockUpload

func (store *ShardedFileStore) LockUpload(id string) error

func (*ShardedFileStore) NewUpload

func (store *ShardedFileStore) NewUpload(info tusd.FileInfo) (id string, err error)

func (*ShardedFileStore) Terminate

func (store *ShardedFileStore) Terminate(id string) error

func (*ShardedFileStore) UnlockUpload

func (store *ShardedFileStore) UnlockUpload(id string) error

func (*ShardedFileStore) UseIn

func (store *ShardedFileStore) UseIn(composer *tusd.StoreComposer)

UseIn sets this store as the core data store in the passed composer and adds all possible extension to it.

func (*ShardedFileStore) WriteChunk

func (store *ShardedFileStore) WriteChunk(id string, offset int64, src io.Reader) (int64, error)

Jump to

Keyboard shortcuts

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