db

package
v0.0.0-...-4137cad Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MyBucket    = []byte("MyBucket")
	SearchIndex = []byte("SearchIndex")
	Users       = []byte("Users")
	Tokens      = []byte("Tokens")
	AuthID      = []byte("AuthID")
	Tags        = []byte("Tags")
)

Functions

func AddShare

func AddShare(hash, owner, user string)

AddShare adds user to share scope of file if the file wasn't shared with him yet

func AddTag

func AddTag(tags []string, id string, repo string) error

AddTag add new key to bucket Tags

func CheckAuthID

func CheckAuthID(token string) (name string)

func CheckRepo

func CheckRepo(owner string, repo []string, hash string) (val int)

func CheckRepoOfHash

func CheckRepoOfHash(hash string) (repo string)

CheckRepoOfHash return the type of file by its hash

func CheckShare

func CheckShare(hash, user string) (shared bool)

CheckShare returns true if user has access to file, otherwise - false

func CleanAuthID

func CleanAuthID()

func CleanSearchIndex

func CleanSearchIndex()

func CleanTokens

func CleanTokens()

func CleanUserFiles

func CleanUserFiles()

func Close

func Close()

func CountMd5

func CountMd5(hash string) (md5 int)

Count all artifacts that have MD5 equal to hash

func CountTotal

func CountTotal(user string) (total int)

CountTotal counts and sets user's total quota usage

func DebugDatabase

func DebugDatabase()

func Delete

func Delete(owner, repo, key string) (total int)

func Edit

func Edit(owner, key, value string, options ...map[string]string)

Edit record about file in DB

func Exists

func Exists(str string, list []string) bool

func FileField

func FileField(hash, field string) (list []string)

FileField provides list of file's field properties

func FileSignatures

func FileSignatures(hash string) (list map[string]string)

FileSignatures returns map with file's owners and their signatures

func GetFileScope

func GetFileScope(hash, owner string) (scope []string)

GetFileScope shows users with whom owner shared a file with particular hash

func GetUserToken

func GetUserToken(user string) (token string)

func Hash

func Hash(key string) (md5, sha256 string)

Hash returns MD5 and SHA256 hashes by ID

func Info

func Info(id string) map[string]string

func InitDB

func InitDB() *bolt.DB

func IntersectOfTags

func IntersectOfTags(tags []string, repo string) (list []string)

IntersectOfTags return IDs of files by all respective tags

func IsFileExists

func IsFileExists(filename string) bool

func IsPublic

func IsPublic(hash string) (public bool)

IsPublic returns true if file is publicly accessible

func LastHash

func LastHash(name, t string) (hash string)

LastHash returns hash of the last uploaded file

func MakePrivate

func MakePrivate(hash, owner string)

func MakePublic

func MakePublic(hash, owner string)

func NameByHash

func NameByHash(hash string) (name string)

NameByHash returns file's name by its ID

func OwnerFilesByRepo

func OwnerFilesByRepo(owner string, repo string) (list []string)

OwnerFilesByRepo returns all public files of owner from specified repo

func OwnerHadThisFile

func OwnerHadThisFile(owner, md5 string) (has bool)

func PrintBucketName

func PrintBucketName(buckets []string) (path string)

func PrintBuckets

func PrintBuckets(b *bolt.Bucket, parents []string)

func QuotaGet

func QuotaGet(user string) (quota int)

QuotaGet returns value of user's disk quota

func QuotaLeft

func QuotaLeft(user string) int

QuotaLeft returns user's quota left space

func QuotaSet

func QuotaSet(user, quota string)

QuotaSet sets changes default storage quota for user

func QuotaUsageCorrect

func QuotaUsageCorrect()

QuotaUsageCorrect updates saved values of quota usage according to file index table

func QuotaUsageGet

func QuotaUsageGet(user string) (stored int)

QuotaUsageGet returns value of used disk quota

func QuotaUsageSet

func QuotaUsageSet(user string, value int)

QuotaUsageSet accepts size of added/removed file and updates quota usage for user

func RebuildShare

func RebuildShare(hash, owner string)

func RegisterUser

func RegisterUser(name, key []byte)

func RemoveShare

func RemoveShare(hash, owner, user string)

RemoveShare removes user from share scope of file if the file was shared with him

func RemoveTags

func RemoveTags(key, list string) error

RemoveTags deletes tag from index bucket and file information. It should be executed on every file deletion to keep DB consistant.

func SaveAuthID

func SaveAuthID(name, token string)

func SaveToken

func SaveToken(name, token string)

func SaveTorrent

func SaveTorrent(hash, torrent []byte)

SaveTorrent saves torrent file for particular template in DB for future usage to prevent regeneration same file again.

func SearchByOneTag

func SearchByOneTag(tag string, repo string) (list []string)

SearchByOneTag is performs search in bucket Tags by tag

func SearchName

func SearchName(query string) (list []string)

SearchName searches for all (public/private) files of all users that have "query" substring in their names

func Tag

func Tag(query string) (list []string, err error)

Tag returns a list of artifacts that contains requested tags. If no records found list will be empty.

func TokenFilesByRepo

func TokenFilesByRepo(token string, repo string) (list []string)

TokenFilesByRepo returns all public/private/shared files of token owner from specified repo

func TokenOwner

func TokenOwner(token string) (name string)

TokenOwner returns the owner of the given token

func Torrent

func Torrent(hash []byte) (val []byte)

Torrent retrieves torrent file for template from DB. If no torrent file found it returns nil.

func UnionByTags

func UnionByTags(tags []string, repo string) (list []string)

UnionByTags return list of the values by one of respective tags

func UserFile

func UserFile(owner, file string) (list []string)

UserFile searches a file among particular user's files. It returns list of hashes of files with required name.

func UserKey

func UserKey(name string) (key string)

UserKey is replaced by UserKeys and left for compatibility. This function should be removed later.

func UserKeys

func UserKeys(name string) (keys []string)

UserKeys returns list of users' GPG keys

func Write

func Write(owner, key, value string, options ...map[string]string) error

Write create record about file in DB

Types

This section is empty.

Jump to

Keyboard shortcuts

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