storage

package
v1.5.7 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

imsto core objects

Index

Constants

View Source
const (
	ASCENDING  = 1
	DESCENDING = -1
)
View Source
const (
	CatView  = "show"
	CatStore = "stores"
	CatThumb = "thumb"
)

consts Cate of Key

View Source
const (
	VC_TOKEN  valueCate = 1
	VC_TICKET valueCate = 2
)

Variables

View Source
var (
	ErrWriteFailed = errors.New("Err: Write file failed")
	ErrEmptyRoof   = errors.New("empty roof")
	ErrEmptyID     = errors.New("empty id")
	ErrZeroSize    = errors.New("zero size")
	ErrInvalidRoof = errors.New("empty roof")
)

errors

View Source
var (
	ErrDbError = errors.New("database error")
)

Functions

func BytesToInt64

func BytesToInt64(buf []byte) int64

func Close added in v1.5.4

func Close()

Close database close, stop ping

func Delete

func Delete(roof, id string) error

Delete ...

func GetURI added in v1.5.4

func GetURI(suffix string) string

GetURI ...

func InitMetaTables

func InitMetaTables()

func Int64ToBytes

func Int64ToBytes(i int64) []byte

func LoadPath

func LoadPath(u string, walk thumbs.WalkFunc) error

LoadPath ...

func ParseTags

func ParseTags(s string) (cdb.StringArray, error)

ParseTags ...

Types

type App

type App struct {
	Id       AppID     `json:"id,omitempty"`
	Version  VerID     `json:"api_ver,omitempty"`
	ApiKey   string    `json:"api_key,omitempty"`
	ApiSalt  string    `json:"api_salt,omitempty"`
	Name     string    `json:"name,omitempty"`
	Created  time.Time `json:"created,omitempty"`
	Disabled bool      `json:"disabled,omitempty"`
}

func LoadApp

func LoadApp(api_key string) (app *App, err error)

func NewApp

func NewApp(name string) (app *App)

func (*App) RequestNewToken

func (a *App) RequestNewToken(uid int) string

func (*App) Save

func (a *App) Save() error

func (*App) TicketRequestLoad

func (a *App) TicketRequestLoad(token, roof string, author int) (ticket *Ticket, err error)

func (*App) TicketRequestNew

func (a *App) TicketRequestNew(roof, token string, uid int, prompt string) (t *apiToken, err error)

TicketRequestNew ... deprecated

func (*App) VerifyToken

func (a *App) VerifyToken(token string) (at *apiToken, err error)

VerifyToken ...

type AppID

type AppID uint16

type Author

type Author uint32

type DBTxer added in v1.5.4

type DBTxer interface {
	Queryer
	Rollback() error
	Commit() error
}

DBTxer ...

type DBer added in v1.5.4

type DBer interface {
	Queryer
	Begin() (*sql.Tx, error)
}

DBer ...

type Entry

type Entry struct {
	Id      imid.IID    `json:"id"`
	Name    string      `json:"name"`
	Size    uint32      `json:"size"`
	Path    string      `json:"path"`
	Status  uint8       `json:"-"`
	Hashes  cdb.Meta    `json:"hashes,omitempty"`
	IDs     StringArray `json:"-"`
	Roofs   StringArray `json:"roofs,omitempty"`
	Tags    StringArray `json:"tags,omitempty"`
	Meta    *iimg.Attr  `json:"meta,omitempty"`
	AppId   AppID       `json:"appid,omitempty"`
	Author  Author      `json:"author,omitempty"`
	Created time.Time   `json:"created,omitempty"`

	Key string `json:"key,omitempty"`   // for upload response
	Err string `json:"error,omitempty"` // for upload response
	// contains filtered or unexported fields
}

func Fetch

func Fetch(in FetchInput) (entry *Entry, err error)

Fetch ...

func NewEntryReader

func NewEntryReader(rs io.ReadSeeker, name string) (e *Entry, err error)

NewEntryReader ...

func PrepareFile

func PrepareFile(file, name string) (entry *Entry, err error)

PrepareFile ...

func PrepareReader

func PrepareReader(r io.ReadSeeker, name string) (entry *Entry, err error)

PrepareReader ...

func (*Entry) GetHash added in v1.5.4

func (e *Entry) GetHash() string

func (*Entry) PushTo

func (e *Entry) PushTo(roof string) (sev cdb.Meta, err error)

PushTo ...

func (*Entry) Store

func (e *Entry) Store(roof string) (ch chan error)

Store ...

func (*Entry) StoredMeta added in v1.5.0

func (e *Entry) StoredMeta() cdb.Meta

StoredMeta ...

func (*Entry) Trek

func (e *Entry) Trek(roof string) (err error)

Trek 处理图片信息并填充

func (*Entry) URI added in v1.5.4

func (e *Entry) URI(sizeOp string) string

URI ..

type FetchInput

type FetchInput struct {
	URI     string
	Roof    string
	Referer string
	AppID   int
	UserID  int
}

FetchInput ...

type File added in v1.5.4

type File = thumbs.File

type HashEntry added in v1.5.0

type HashEntry struct {
	ID   IID    `json:"id"`
	Path string `json:"path"`
}

HashEntry ...

type HttpError

type HttpError = thumbs.CodeError

HttpError ...

func NewHttpError

func NewHttpError(code int, text string) *HttpError

NewHttpError ...

type IID

type IID = imid.IID

type MetaFilter

type MetaFilter struct {
	Tags   string
	App    AppID
	Author Author
}

MetaFilter ...

type MetaWrap

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

MetaWrap ...

func (*MetaWrap) BatchSave

func (mw *MetaWrap) BatchSave(entries []*Entry) error

func (*MetaWrap) Browse

func (mw *MetaWrap) Browse(limit, offset int, sort map[string]int, filter MetaFilter) (a []*Entry, err error)

func (*MetaWrap) Count

func (mw *MetaWrap) Count(filter MetaFilter) (t int, err error)

Count ...

func (*MetaWrap) Delete

func (mw *MetaWrap) Delete(id string) error

func (*MetaWrap) GetHash

func (mw *MetaWrap) GetHash(hash string) (he *HashEntry, err error)

func (*MetaWrap) GetMapping

func (mw *MetaWrap) GetMapping(id string) (*mapItem, error)

func (*MetaWrap) GetMeta

func (mw *MetaWrap) GetMeta(id string) (entry *Entry, err error)

func (*MetaWrap) MapTags

func (mw *MetaWrap) MapTags(id string, tags string) error

func (*MetaWrap) NextID added in v1.5.0

func (mw *MetaWrap) NextID() (nid uint64, err error)

NextID ...

func (*MetaWrap) Ready

func (mw *MetaWrap) Ready(entry *Entry) error

func (*MetaWrap) Save

func (mw *MetaWrap) Save(entry *Entry, isUpdate bool) error

Save ...

func (*MetaWrap) SetDone

func (mw *MetaWrap) SetDone(id string, sev cdb.Meta) error

func (*MetaWrap) UnmapTags

func (mw *MetaWrap) UnmapTags(id string, tags string) error

type MetaWrapper

type MetaWrapper interface {
	Browse(limit, offset int, sort map[string]int, filter MetaFilter) ([]*Entry, error)
	Count(filter MetaFilter) (int, error)
	NextID() (uint64, error)
	Ready(entry *Entry) error
	SetDone(id string, sev cdb.Meta) error
	Save(entry *Entry, isUpdate bool) error
	BatchSave(entries []*Entry) error
	GetMeta(id string) (*Entry, error)
	GetHash(hash string) (*HashEntry, error)
	GetMapping(id string) (*mapItem, error)
	Delete(id string) error
	MapTags(id string, tags string) error
	UnmapTags(id string, tags string) error
}

MetaWrapper ...

func NewMetaWrapper

func NewMetaWrapper(roof string) (mw MetaWrapper)

NewMetaWrapper ...

type Queryer added in v1.5.4

type Queryer interface {
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	Exec(query string, args ...interface{}) (sql.Result, error)
}

Queryer ...

type StringArray

type StringArray = cdb.StringArray

type StringSlice

type StringSlice = cdb.StringSlice

type Ticket

type Ticket struct {
	AppID  AppID  `json:"appid,omitempty"`
	Author Author `json:"author,omitempty"`
	Prompt string `json:"prompt,omitempty"`

	ImgId   string `json:"img_id,omitempty"`
	ImgPath string `json:"img_path,omitempty"`
	Done    bool   `json:"done,omitempty"`
	// contains filtered or unexported fields
}

func (*Ticket) GetId

func (t *Ticket) GetId() int

type VerID

type VerID uint8

Directories

Path Synopsis
s3c

Jump to

Keyboard shortcuts

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