schema

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const FORMAT = "  %-10s  %-10s  %-16s  %s\n"

Client, Status, TaskId, Note

View Source
const NAME_WIDTH = 30

Variables

This section is empty.

Functions

func Init

func Init(dbfile string, verboseLevel int) (db *gorm.DB, err error)

func PrintDownloads

func PrintDownloads(output io.Writer, title string, downloads []*Download)

func PrintResourceDownloads

func PrintResourceDownloads(output io.Writer, title string, resourceDownloads []*ResourceDownload)

Types

type Download

type Download struct {
	ID         uint      `gorm:"primarykey" json:"id"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	DownloadId string    `json:"download_id"` // download task id in client
	FileId     string    `json:"file_id"`
	Identifier string    `json:"identifier"`
	Site       string    `json:"site"`
	FileUrl    string    `json:"file_url"`
	Filename   string    `json:"filename"`
	SavePath   string    `json:"save_path"`
	ResourceId string    `json:"resource_id"`
	Status     string    `json:"status"` // (empty)|downloading|completed|error
	Note       string    `json:"note"`
	Client     string    `json:"client"`
}

a download task in client. For convenience, it implements client.DownloadTask.

func (*Download) GetFilename

func (d *Download) GetFilename() string

func (*Download) GetPaused

func (d *Download) GetPaused() bool

func (*Download) GetSavePath

func (d *Download) GetSavePath() string

func (*Download) GetUrl

func (d *Download) GetUrl() string

type ResourceDownload

type ResourceDownload struct {
	ID         uint      `gorm:"primarykey" json:"id"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	ResourceId string    `json:"resource_id"`
	Identifier string    `json:"identifier"`
	Site       string    `json:"site"`
	Status     string    `json:"status"`
	Size       int64     `json:"size"`
	Number     string    `json:"number"`
	Title      string    `json:"title"`
	Author     string    `json:"author"`
	Client     string    `json:"client"`
	SavePath   string    `json:"save_path"`
	Note       string    `json:"note"`
	Failed     int       `json:"failed"` // failed times count
	Tags       Tags      `gorm:"type:string" json:"tags"`
}

Do NOT embed gorm.Model as we need to set json tag

func (*ResourceDownload) GetFilename

func (r *ResourceDownload) GetFilename() (filename string)

Return suitable folder name

type Tags

type Tags []string

Custom sql type. A custom sql type T must implements Valuer and *T must implements Scanner

func (Tags) GetMeta

func (t Tags) GetMeta(name string) string

func (Tags) GetMetaArray

func (t Tags) GetMetaArray(name string) (arr []string)

func (*Tags) Scan

func (t *Tags) Scan(value interface{}) error

func (Tags) Value

func (t Tags) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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