file

package
v0.0.0-...-cba5bb6 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: Zlib Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteFile

func DeleteFile(s *Store, db *gorm.DB, t *Token, fm *FileMetadata) error

func DeleteFileWithPath

func DeleteFileWithPath(s *Store, db *gorm.DB, t *Token, p string) error

func DeleteToken

func DeleteToken(s *Store, db *gorm.DB, token *Token) error

func FindFile

func FindFile(db *gorm.DB, t *Token, p string) (*FileVersion, *FileMetadata, error)

func FindFileBySHA

func FindFileBySHA(db *gorm.DB, t *Token, sha string) (*FileVersion, *FileMetadata, error)

func FindFileByShareUUID

func FindFileByShareUUID(db *gorm.DB, uuid string) (*Token, *FileVersion, *FileMetadata, error)

func GetStoreId

func GetStoreId(prefix uint64) string

func SaveFile

func SaveFile(s *Store, db *gorm.DB, t *Token, body io.Reader, fp FileParams) (*FileVersion, *FileMetadata, error)

Types

type FileMetadata

type FileMetadata struct {
	ID              uint64    `gorm:"primary_key" json:"-"`
	TokenID         uint64    `gorm:"type:bigint not null REFERENCES tokens(id)" json:"-"`
	LastVersionID   uint64    `gorm:"type:bigint" json:"-"`
	ShareUUID       *string   `gorm:"null;type:varchar(255) unique" json:"share_uuid"`
	CountRead       uint64    `gorm:"not null;default:0" json:"count_read"`
	CountWrite      uint64    `gorm:"not null;default:0" json:"count_write"`
	Path            string    `gorm:"not null" json:"path"`
	Filename        string    `gorm:"not null" json:"filename"`
	KeepN           uint64    `gorm:"not null;default:7" json:"keep_n_versions"`
	AcceptableAge   uint64    `gorm:"not null;default:0" json:"acceptable_age"`
	AcceptableDelta uint64    `gorm:"not null;default:0" json:"acceptable_delta"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
}

func (*FileMetadata) FullPath

func (fm *FileMetadata) FullPath() string

type FileMetadataAndVersion

type FileMetadataAndVersion struct {
	FileMetadata *FileMetadata
	Versions     []*FileVersion
}

func ListFilesInPath

func ListFilesInPath(db *gorm.DB, t *Token, p string, strict bool) ([]FileMetadataAndVersion, error)

type FileParams

type FileParams struct {
	KeepN           *uint64 `form:"keep_n" json:"keep_n"`
	AcceptableAge   *uint64 `form:"age" json:"age"`
	AcceptableDelta *uint64 `form:"delta" json:"delta"`
	ContentType     string
	FullPath        string
}

type FileVersion

type FileVersion struct {
	ID uint64 `gorm:"primary_key" json:"id"`

	// denormalized for simplicity
	TokenID        uint64 `gorm:"type:bigint not null REFERENCES tokens(id)" json:"-"`
	FileMetadataID uint64 `gorm:"type:bigint not null REFERENCES file_metadata(id)" json:"-"`

	Size        uint64    `gorm:"not null" json:"size"`
	SHA256      string    `gorm:"not null" json:"sha"`
	StoreID     string    `gorm:"type:varchar(255) not null unique" json:"-"`
	ContentType string    `gorm:"null;type:varchar(255)" json:"content_type"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"-"`
}

func ListVersionsFile

func ListVersionsFile(db *gorm.DB, t *Token, fm *FileMetadata) ([]*FileVersion, error)

type FilesPerToken

type FilesPerToken struct {
	Token *Token
	Files []FileMetadataAndVersion
}

type Store

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

func NewStore

func NewStore(j string) (*Store, error)

make sure judoc is listening on localhost otherwise we have to do ssl

func (*Store) DeleteFile

func (s *Store) DeleteFile(namespace, id string) error

func (*Store) DownloadFile

func (s *Store) DownloadFile(key string, namespace, id string) (io.Reader, error)

func (*Store) RemoveMany

func (s *Store) RemoveMany(namespace string, remove []FileVersion) error

this leak of FileVersion here is not needed, but it is nice for logging

func (*Store) UploadFile

func (s *Store) UploadFile(key string, namespace string, id string, body io.Reader) (string, int64, error)

type StreamByteCounter

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

func (*StreamByteCounter) Sum

func (s *StreamByteCounter) Sum() string

func (*StreamByteCounter) Write

func (s *StreamByteCounter) Write(p []byte) (nn int, err error)

type Token

type Token struct {
	ID         uint64 `gorm:"primary_key"`
	UUID       string `gorm:"not null;type:varchar(255) unique"`
	Salt       string `gorm:"not null;type:varchar(32)"`
	Name       string `gorm:"null;type:varchar(255)"`
	UserID     uint64 `gorm:"type:bigint not null REFERENCES users(id)"`
	WriteOnly  bool   `gorm:"not null"`
	SizeUsed   uint64 `gorm:"not null;default:0"`
	CountFiles uint64 `gorm:"not null;default:0"`
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

Jump to

Keyboard shortcuts

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