gfsdb

package
v0.0.0-...-2b2c7ec Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: BSD-3-Clause, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CN_F      = "c_f"
	CN_MARK   = "c_mark"
	CN_FILE   = "c_file"
	CN_FOLDER = "c_folder"
)
View Source
const (
	ES_RUNNING = "running"
	ES_DONE    = "done"
	ES_ERROR   = "error"
	ES_IGNORE  = "ignore"
	ES_NONE    = "none"

	//
	VS_VERIFIED = "verified"
	VS_ZERO     = "zero"
	VS_REDO     = "redo"
	VS_ERROR    = "error"
)
View Source
const (
	FS_N = "N" //normal
	FS_D = "D" //deleted
)
View Source
const (
	FT_FILE   = "file"
	FT_FOLDER = "folder"
)

Variables

View Source
var C = func(n string) *mgo.Collection {
	panic("the gfs database caller is not initial")
}
View Source
var CreateOutPath = func(f *F) string {
	if len(f.Path) < 1 {
		return ""
	}
	var out = OutPathPre + strings.TrimSuffix(f.Path, filepath.Ext(f.Path))
	if f.Path == out {
		return out + "_"
	} else {
		return out
	}
}
View Source
var ExternalExecSupported = []string{}
View Source
var Indexes = map[string]map[string]mgo.Index{
	CN_F: map[string]mgo.Index{
		"f_name": mgo.Index{
			Key: []string{"name"},
		},
		"f_filename": mgo.Index{
			Key: []string{"filename"},
		},
		"f_pub": mgo.Index{
			Key: []string{"pub"},
		},
		"f_sha": mgo.Index{
			Key: []string{"sha"},
		},
		"f_md5": mgo.Index{
			Key: []string{"md5"},
		},
		"f_ext": mgo.Index{
			Key: []string{"ext"},
		},
		"f_size": mgo.Index{
			Key: []string{"size"},
		},
		"f_type": mgo.Index{
			Key: []string{"type"},
		},
		"f_exec": mgo.Index{
			Key: []string{"exec"},
		},
		"f_status": mgo.Index{
			Key: []string{"status"},
		},
		"f_time": mgo.Index{
			Key: []string{"time"},
		},
	},
}
View Source
var MockStartTaskErr int = 0
View Source
var OutPathPre = ""
View Source
var ShowLog = 0

Functions

func CountF

func CountF() (int, error)

func CountFile

func CountFile() (int, error)

func CountFileExt

func CountFileExt(oid, owner, name string, pid, status []string) (extCount []util.Map, err error)

func DoAddTask

func DoAddTask(rf *F) (int, error)

func DoAddTaskRemote

func DoAddTaskRemote(rf *F) error

func FOI_F

func FOI_F(rf *F) (int, error)

func FOI_File

func FOI_File(file *File) (int, error)

func IsExternalSupported

func IsExternalSupported(ext string) bool

func ListF_m

func ListF_m(ids []string) (map[string]*F, error)

func ListTaskIds

func ListTaskIds() ([]string, error)

func MapVal

func MapVal(v interface{}) (util.Map, bool)

func MapValV

func MapValV(v interface{}) interface{}

func RemoveFile

func RemoveFile(id ...string) (removed int, err error)

func SyncAllTask

func SyncAllTask(exts []string) (total int, err error)

func SyncAllTaskV

func SyncAllTaskV(exts, ignore []string) (total int, err error)

func SyncTask

func SyncTask(exts, ignore []string, limit int) (int, error)

func UpdateExecF

func UpdateExecF(id, es string) error

func UpdateF

func UpdateF(id string, set bson.M) error

func UpdateFile

func UpdateFile(file *File) error

func UpdateFileParent

func UpdateFileParent(fids []string, pid string) error

func UpdateVerifyF

func UpdateVerifyF(id, es string) error

func VerifyVideo

func VerifyVideo(diri, diro string, exts, ids, ignore []string) (total, fail int, err error)

func VerifyVideoF

func VerifyVideoF(diri, diro string, rf *F) (int, error)

Types

type F

type F struct {
	Id       string   `bson:"_id" json:"id"`
	Name     string   `bson:"name" json:"name"`
	Filename string   `bson:"filename" json:"filename"` //upload file name
	Pub      string   `bson:"pub" json:"pub"`           //public path.
	SHA      string   `bson:"sha" json:"sha"`           //file sha
	MD5      string   `bson:"md5" json:"md5"`           //file md5
	EXT      string   `bson:"ext" json:"ext"`           //file externd
	Size     int64    `bson:"size" json:"size"`         //file size.
	Type     string   `bson:"type" json:"type"`         //mimetype
	Path     string   `bson:"path" json:"-"`            //file save path.
	Exec     string   `bson:"exec" json:"exec"`         //the exec status
	Info     util.Map `bson:"info" json:"info"`         //the extern info.
	Status   string   `bson:"status" json:"status"`     //file status
	Time     int64    `bson:"time" json:"time"`         //upload time.
}

func FindF

func FindF(id string) (*F, error)

func FindFv

func FindFv(query bson.M) (*F, error)

func FindHashF

func FindHashF(sha, md5 string) (*F, error)

func FindMarkF

func FindMarkF(mark string) (*F, error)

func FindPubF

func FindPubF(pub string) (*F, error)

func ListF

func ListF(ids []string) ([]*F, error)

func ListFv

func ListFv(query bson.M) ([]*F, error)

func ListHashF

func ListHashF(sha, md5 []string) ([]*F, error)

func ListMarkF

func ListMarkF(mark []string) ([]*F, error)

func ListMarkFv

func ListMarkFv(mark []string) ([]*F, map[string]string, error)

func ListPubF

func ListPubF(pub []string) ([]*F, error)

func ListShaF

func ListShaF(sha []string) ([]*F, error)

func (*F) ToBsonM

func (f *F) ToBsonM() bson.M

type FFCM_H

type FFCM_H struct {
}

func NewFFCM_H

func NewFFCM_H() *FFCM_H

func (*FFCM_H) OnDone

func (f *FFCM_H) OnDone(dtcm *dtm.DTCM_S, task *dtm.Task) error

func (*FFCM_H) OnStart

func (f *FFCM_H) OnStart(dtcm *dtm.DTCM_S, task *dtm.Task)

func (*FFCM_H) ParseRes

func (f *FFCM_H) ParseRes(task *dtm.Task, res util.Map) error

type File

type File struct {
	Id     string   `bson:"_id" json:"id"`
	Fid    string   `bson:"fid" json:"fid"`
	Pid    string   `bson:"pid" json:"pid"`
	Oid    string   `bson:"oid" json:"oid"`
	Owner  string   `bson:"owner" json:"owner"`
	Name   string   `bson:"name" json:"name"`
	EXT    string   `bson:"ext" json:"ext"`   //file externd
	Type   string   `bson:"type" json:"type"` //type
	Tags   []string `bson:"tags" json:"tags"`
	Desc   string   `bson:"desc" json:"desc"`
	Status string   `bson:"status" json:"status"` //file status
	Time   int64    `bson:"time" json:"time"`     //upload time.
}

func FindFile

func FindFile(id string) (*File, error)

func ListFile

func ListFile(oid, owner, name, typ string, pid, ext, tags, status []string) ([]*File, error)

func ListFilePaged

func ListFilePaged(oid, owner, name, typ string, pid, ext, tags, status []string, sort string, reverseExt, pn, ps, retTotal, retExtCount int) (fs []*File, total int, extCount []util.Map, err error)

type Mark

type Mark struct {
	Id  string `bson:"_id" json:"id"`
	Fid string `bson:"fid" json:"fid"`
}

func FOI_Mark

func FOI_Mark(mark, fid string) (*Mark, error)

Jump to

Keyboard shortcuts

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