metadata

package
v0.0.0-...-233af93 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	Config *Config
	// contains filtered or unexported fields
}

Backend object

func NewBackend

func NewBackend(config *Config) (b *Backend, err error)

NewBackend instantiate a new File Data Backend from configuration passed as argument

func (*Backend) CountUploadFiles

func (b *Backend) CountUploadFiles(uploadID string) (count int, err error)

CountUploadFiles count how many files have been added to an upload

func (*Backend) CountUserTokens

func (b *Backend) CountUserTokens(userID string) (count int, err error)

CountUserTokens count how many token a user has

func (*Backend) CountUsers

func (b *Backend) CountUsers() (count int, err error)

CountUsers count the number of user in the DB

func (*Backend) CreateFile

func (b *Backend) CreateFile(file *common.File) (err error)

CreateFile persist a new file to the database

func (*Backend) CreateSetting

func (b *Backend) CreateSetting(setting *common.Setting) (err error)

CreateSetting create a new setting in DB

func (*Backend) CreateToken

func (b *Backend) CreateToken(token *common.Token) (err error)

CreateToken create a new token in DB

func (*Backend) CreateUpload

func (b *Backend) CreateUpload(upload *common.Upload) (err error)

CreateUpload create a new upload in DB

func (*Backend) CreateUser

func (b *Backend) CreateUser(user *common.User) (err error)

CreateUser create a new user in DB

func (*Backend) DeleteExpiredUploads

func (b *Backend) DeleteExpiredUploads() (removed int, err error)

DeleteExpiredUploads soft delete all expired uploads

func (*Backend) DeleteSetting

func (b *Backend) DeleteSetting(key string) (err error)

DeleteSetting delete a setting from DB

func (*Backend) DeleteToken

func (b *Backend) DeleteToken(tokenStr string) (deleted bool, err error)

DeleteToken remove a token from the DB

func (*Backend) DeleteUpload

func (b *Backend) DeleteUpload(uploadID string) (err error)

DeleteUpload soft delete upload ( just set upload.DeletedAt field ) and remove all files

func (*Backend) DeleteUser

func (b *Backend) DeleteUser(userID string) (deleted bool, err error)

DeleteUser delete a user from the DB

func (*Backend) DeleteUserUploads

func (b *Backend) DeleteUserUploads(userID string, tokenStr string) (removed int, err error)

DeleteUserUploads delets all uploads matching the user and token filters

func (*Backend) Export

func (b *Backend) Export(path string) (err error)

Export exports all metadata from the backend to a compressed binary file

func (*Backend) ForEachFile

func (b *Backend) ForEachFile(f func(file *common.File) error) (err error)

ForEachFile execute f for every file in the database

func (*Backend) ForEachRemovedFile

func (b *Backend) ForEachRemovedFile(f func(file *common.File) error) (err error)

ForEachRemovedFile execute f for each file with the status "removed"

func (*Backend) ForEachSetting

func (b *Backend) ForEachSetting(f func(setting *common.Setting) error) (err error)

ForEachSetting execute f for every setting in the database

func (*Backend) ForEachToken

func (b *Backend) ForEachToken(f func(token *common.Token) error) (err error)

ForEachToken execute f for every token in the database

func (*Backend) ForEachUpload

func (b *Backend) ForEachUpload(f func(upload *common.Upload) error) (err error)

ForEachUpload execute f for every upload in the database

func (*Backend) ForEachUploadFiles

func (b *Backend) ForEachUploadFiles(uploadID string, f func(file *common.File) error) (err error)

ForEachUploadFiles execute f for each file of the upload

func (*Backend) ForEachUserUploads

func (b *Backend) ForEachUserUploads(userID string, tokenStr string, f func(upload *common.Upload) error) (err error)

ForEachUserUploads execute f for all upload matching the user and token filters

func (*Backend) ForEachUsers

func (b *Backend) ForEachUsers(f func(user *common.User) error) (err error)

ForEachUsers execute f for every user in the database

func (*Backend) GetFile

func (b *Backend) GetFile(fileID string) (file *common.File, err error)

GetFile return a file from the database ( nil and no error if not found )

func (*Backend) GetFiles

func (b *Backend) GetFiles(uploadID string) (files []*common.File, err error)

GetFiles return all files for the given upload ID

func (*Backend) GetServerStatistics

func (b *Backend) GetServerStatistics() (stats *common.ServerStats, err error)

GetServerStatistics return statistics about user all uploads

func (*Backend) GetSetting

func (b *Backend) GetSetting(key string) (setting *common.Setting, err error)

GetSetting get a setting from DB

func (*Backend) GetToken

func (b *Backend) GetToken(tokenStr string) (token *common.Token, err error)

GetToken return a token from the DB ( return nil and non error if not found )

func (*Backend) GetTokens

func (b *Backend) GetTokens(userID string, pagingQuery *common.PagingQuery) (tokens []*common.Token, cursor *paginator.Cursor, err error)

GetTokens return all tokens for a user

func (*Backend) GetUpload

func (b *Backend) GetUpload(ID string) (upload *common.Upload, err error)

GetUpload return an upload from the DB ( return nil and no error if not found )

func (*Backend) GetUploadStatistics

func (b *Backend) GetUploadStatistics(userID *string, tokenStr *string) (uploads int, files int, size int64, err error)

GetUploadStatistics return statistics about uploads for userID and tokenStr params : nil doesn't activate the filter, empty string enables the filter with an empty value to generate statistics about anonymous upload

func (*Backend) GetUploads

func (b *Backend) GetUploads(userID string, tokenStr string, withFiles bool, pagingQuery *common.PagingQuery) (uploads []*common.Upload, cursor *paginator.Cursor, err error)

GetUploads return uploads from DB userID and tokenStr are filters set withFiles to also fetch the files

func (*Backend) GetUser

func (b *Backend) GetUser(ID string) (user *common.User, err error)

GetUser return a user from DB ( return nil and no error if not found )

func (*Backend) GetUserStatistics

func (b *Backend) GetUserStatistics(userID string, tokenStr *string) (stats *common.UserStats, err error)

GetUserStatistics return statistics about user uploads for tokenStr params : nil doesn't activate the filter, empty string enables the filter with an empty value to generate statistics about upload without a token

func (*Backend) GetUsers

func (b *Backend) GetUsers(provider string, withTokens bool, pagingQuery *common.PagingQuery) (users []*common.User, cursor *paginator.Cursor, err error)

GetUsers return all users provider is an optional filter

func (*Backend) Import

func (b *Backend) Import(path string) (err error)

Import imports metadata from a compressed binary file

func (*Backend) PurgeDeletedUploads

func (b *Backend) PurgeDeletedUploads() (removed int, err error)

PurgeDeletedUploads ensure all files from an expired upload have been deleted Then delete the upload and files for good

func (*Backend) RemoveFile

func (b *Backend) RemoveFile(file *common.File) error

RemoveFile change the file status to removed The file will then be deleted from the data backend by the server and the status changed to deleted.

func (*Backend) RemoveUploadFiles

func (b *Backend) RemoveUploadFiles(uploadID string) (err error)

RemoveUploadFiles set the file status to removed for all files of an upload The files are then deleted by the servers and their status set to removed

func (*Backend) Shutdown

func (b *Backend) Shutdown() (err error)

Shutdown close the metadata backend

func (*Backend) UpdateFile

func (b *Backend) UpdateFile(file *common.File, status string) error

UpdateFile update a file in DB. Status ensure the file status has not changed since loaded

func (*Backend) UpdateFileStatus

func (b *Backend) UpdateFileStatus(file *common.File, oldStatus string, newStatus string) error

UpdateFileStatus update a file status in DB. oldStatus ensure the file status has not changed since loaded

func (*Backend) UpdateSetting

func (b *Backend) UpdateSetting(key string, oldValue string, newValue string) (err error)

UpdateSetting update a setting in DB

func (*Backend) UpdateUser

func (b *Backend) UpdateUser(user *common.User) (err error)

UpdateUser update user info in DB

type Config

type Config struct {
	Driver           string
	ConnectionString string
	EraseFirst       bool
	Debug            bool
}

Config metadata backend configuration

func NewConfig

func NewConfig(params map[string]interface{}) (config *Config)

NewConfig instantiate a new default configuration and override it with configuration passed as argument

Jump to

Keyboard shortcuts

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