database

package
v0.0.0-...-29a3764 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusRemove ...
	StatusRemove = iota
	// StatusActive ...
	StatusActive
)
View Source
const (
	// BTItemBucket ...
	BTItemBucket = "BTItem"

	// TorrentHistoryBucket ...
	TorrentHistoryBucket = "TorrentHistory"

	// TorrentAssignMetadataBucket ...
	TorrentAssignMetadataBucket = "TorrentAssignMetadata"
	// TorrentAssignItemBucket ...
	TorrentAssignItemBucket = "TorrentAssignItem"

	// QueryHistoryBucket ...
	QueryHistoryBucket = "QueryHistory"
)

Variables

View Source
var CacheBuckets = [][]byte{
	CommonBucket,
}

CacheBuckets represents buckets in Cache database

View Source
var (
	// CommonBucket ...
	CommonBucket = []byte("Common")
)

Functions

func CreateBoltDB

func CreateBoltDB(conf *config.Configuration, fileName string, backupFileName string) (*bolt.DB, error)

CreateBoltDB ...

func CreateStormDB

func CreateStormDB(conf *config.Configuration, fileName string, backupFileName string) (*storm.DB, error)

CreateStormDB ...

func GetStormDB

func GetStormDB() *storm.DB

GetStormDB returns common database

func ParseCacheItem

func ParseCacheItem(item []byte) (int64, []byte)

ParseCacheItem ...

func RestoreBackup

func RestoreBackup(databasePath string, backupPath string)

RestoreBackup ...

Types

type BTItem

type BTItem struct {
	InfoHash string   `json:"infoHash" storm:"id"`
	ID       int      `json:"id"`
	State    int      `json:"state"`
	Type     string   `json:"type"`
	Files    []string `json:"files"`
	ShowID   int      `json:"showid"`
	Season   int      `json:"season"`
	Episode  int      `json:"episode"`
	Query    string   `json:"query"`
}

BTItem ...

type BoltDatabase

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

BoltDatabase ...

func GetBolt

func GetBolt() *BoltDatabase

GetBolt returns common database

func GetCache

func GetCache() *BoltDatabase

GetCache returns Cache database

func InitCacheDB

func InitCacheDB(conf *config.Configuration) (*BoltDatabase, error)

InitCacheDB ...

func (*BoltDatabase) AsWriter

func (d *BoltDatabase) AsWriter(bucket []byte, key string) *DBWriter

AsWriter ...

func (*BoltDatabase) BatchDelete

func (d *BoltDatabase) BatchDelete(bucket []byte, keys []string) error

BatchDelete ...

func (*BoltDatabase) BatchSet

func (d *BoltDatabase) BatchSet(bucket []byte, objects map[string]string) error

BatchSet ...

func (*BoltDatabase) BatchSetBytes

func (d *BoltDatabase) BatchSetBytes(bucket []byte, objects map[string][]byte) error

BatchSetBytes ...

func (*BoltDatabase) BatchSetObject

func (d *BoltDatabase) BatchSetObject(bucket []byte, objects map[string]interface{}) error

BatchSetObject ...

func (*BoltDatabase) BucketExists

func (d *BoltDatabase) BucketExists(bucket []byte) (res bool)

BucketExists checks if bucket already exists in the database

func (*BoltDatabase) CacheCleanup

func (d *BoltDatabase) CacheCleanup()

CacheCleanup ...

func (*BoltDatabase) CheckBucket

func (d *BoltDatabase) CheckBucket(bucket []byte) error

CheckBucket ...

func (*BoltDatabase) Close

func (d *BoltDatabase) Close()

Close ...

func (*BoltDatabase) CreateBackup

func (d *BoltDatabase) CreateBackup(backupPath string)

CreateBackup ...

func (*BoltDatabase) Delete

func (d *BoltDatabase) Delete(bucket []byte, key string) error

Delete ...

func (*BoltDatabase) DeleteWithPrefix

func (d *BoltDatabase) DeleteWithPrefix(bucket []byte, prefix []byte)

DeleteWithPrefix ...

func (*BoltDatabase) ForEach

func (d *BoltDatabase) ForEach(bucket []byte, callback callBackWithError) error

ForEach ...

func (*BoltDatabase) Get

func (d *BoltDatabase) Get(bucket []byte, key string) (string, error)

Get ...

func (*BoltDatabase) GetBytes

func (d *BoltDatabase) GetBytes(bucket []byte, key string) (value []byte, err error)

GetBytes ...

func (*BoltDatabase) GetCached

func (d *BoltDatabase) GetCached(bucket []byte, key string) (string, error)

GetCached ...

func (*BoltDatabase) GetCachedBool

func (d *BoltDatabase) GetCachedBool(bucket []byte, key string) (bool, error)

GetCachedBool ...

func (*BoltDatabase) GetCachedBytes

func (d *BoltDatabase) GetCachedBytes(bucket []byte, key string) (cacheValue []byte, err error)

GetCachedBytes ...

func (*BoltDatabase) GetCachedObject

func (d *BoltDatabase) GetCachedObject(bucket []byte, key string, item interface{}) (err error)

GetCachedObject ...

func (*BoltDatabase) GetFilename

func (d *BoltDatabase) GetFilename() string

GetFilename returns bolt filename

func (*BoltDatabase) GetObject

func (d *BoltDatabase) GetObject(bucket []byte, key string, item interface{}) (err error)

GetObject ...

func (*BoltDatabase) Has

func (d *BoltDatabase) Has(bucket []byte, key string) (ret bool)

Has checks for existence of a key

func (*BoltDatabase) MaintenanceRefreshHandler

func (d *BoltDatabase) MaintenanceRefreshHandler()

MaintenanceRefreshHandler ...

func (*BoltDatabase) RecreateBucket

func (d *BoltDatabase) RecreateBucket(bucket []byte) error

RecreateBucket ...

func (*BoltDatabase) Seek

func (d *BoltDatabase) Seek(bucket []byte, prefix string, callback callBack) error

Seek ...

func (*BoltDatabase) Set

func (d *BoltDatabase) Set(bucket []byte, key string, value string) error

Set ...

func (*BoltDatabase) SetBytes

func (d *BoltDatabase) SetBytes(bucket []byte, key string, value []byte) error

SetBytes ...

func (*BoltDatabase) SetCached

func (d *BoltDatabase) SetCached(bucket []byte, seconds int, key string, value string) error

SetCached ...

func (*BoltDatabase) SetCachedBool

func (d *BoltDatabase) SetCachedBool(bucket []byte, seconds int, key string, value bool) error

SetCachedBool ...

func (*BoltDatabase) SetCachedBytes

func (d *BoltDatabase) SetCachedBytes(bucket []byte, seconds int, key string, value []byte) error

SetCachedBytes ...

func (*BoltDatabase) SetCachedObject

func (d *BoltDatabase) SetCachedObject(bucket []byte, seconds int, key string, item interface{}) error

SetCachedObject ...

func (*BoltDatabase) SetObject

func (d *BoltDatabase) SetObject(bucket []byte, key string, item interface{}) error

SetObject ...

type DBWriter

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

DBWriter ...

func (*DBWriter) Write

func (w *DBWriter) Write(b []byte) (n int, err error)

Write ...

type LibraryItem

type LibraryItem struct {
	ID        int `storm:"id"`
	MediaType int `storm:"index"`
	State     int `storm:"index"`
	ShowID    int `storm:"index"`
}

LibraryItem ...

type QueryHistory

type QueryHistory struct {
	ID    string    `storm:"id"`
	Type  string    `storm:"index"`
	Query string    `storm:"index"`
	Dt    time.Time `storm:"index"`
}

QueryHistory ...

type SqliteDatabase

type SqliteDatabase struct {
	*sql.DB
	// contains filtered or unexported fields
}

SqliteDatabase ...

type StormDatabase

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

StormDatabase ...

func GetStorm

func GetStorm() *StormDatabase

GetStorm returns common database

func InitStormDB

func InitStormDB(conf *config.Configuration) (*StormDatabase, error)

InitStormDB ...

func (*StormDatabase) AddSearchHistory

func (d *StormDatabase) AddSearchHistory(historyType, query string)

AddSearchHistory adds query to search history, according to media type

func (*StormDatabase) AddTorrentHistory

func (d *StormDatabase) AddTorrentHistory(infoHash, name string, b []byte)

AddTorrentHistory saves last used torrent

func (d *StormDatabase) AddTorrentLink(tmdbID, infoHash string, b []byte)

AddTorrentLink saves link between torrent file and tmdbID entry

func (*StormDatabase) CleanSearchHistory

func (d *StormDatabase) CleanSearchHistory(historyType string)

CleanSearchHistory cleans search history for selected media type

func (d *StormDatabase) CleanupTorrentLink(infoHash string)

CleanupTorrentLink ...

func (*StormDatabase) Close

func (d *StormDatabase) Close()

Close ...

func (*StormDatabase) CreateBackup

func (d *StormDatabase) CreateBackup(backupPath string)

CreateBackup ...

func (*StormDatabase) DeleteBTItem

func (d *StormDatabase) DeleteBTItem(infoHash string) error

DeleteBTItem ...

func (*StormDatabase) GetBTItem

func (d *StormDatabase) GetBTItem(infoHash string) *BTItem

GetBTItem ...

func (*StormDatabase) GetFilename

func (d *StormDatabase) GetFilename() string

GetFilename returns bolt filename

func (*StormDatabase) MaintenanceRefreshHandler

func (d *StormDatabase) MaintenanceRefreshHandler()

MaintenanceRefreshHandler ...

func (*StormDatabase) RemoveSearchHistory

func (d *StormDatabase) RemoveSearchHistory(historyType, query string)

RemoveSearchHistory removes query from the history

func (*StormDatabase) UpdateBTItem

func (d *StormDatabase) UpdateBTItem(infoHash string, mediaID int, mediaType string, files []string, query string, infos ...int) error

UpdateBTItem ...

func (*StormDatabase) UpdateBTItemFiles

func (d *StormDatabase) UpdateBTItemFiles(infoHash string, files []string) error

UpdateBTItemFiles ...

func (*StormDatabase) UpdateBTItemStatus

func (d *StormDatabase) UpdateBTItemStatus(infoHash string, status int) error

UpdateBTItemStatus ...

type TorrentAssignItem

type TorrentAssignItem struct {
	Pk       int    `storm:"id,increment"`
	InfoHash string `storm:"index"`
	TmdbID   int    `storm:"unique"`
}

TorrentAssignItem ...

type TorrentAssignMetadata

type TorrentAssignMetadata struct {
	InfoHash string `storm:"id"`
	Metadata []byte
}

TorrentAssignMetadata ...

type TorrentHistory

type TorrentHistory struct {
	InfoHash string `storm:"id"`
	Name     string
	Dt       time.Time `storm:"index"`
	// Dt       int64 `storm:"index"`
	Metadata []byte
}

TorrentHistory ...

Jump to

Keyboard shortcuts

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