db

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserSchemaNs = "UserSchemaNs"
	FileSchemaNs = "FileSchemaNs"
	UserIDsNs    = "UserIDsNs"
	UsersNs      = "UsersNs"
	RolesNs      = "RolesNs"
	FileInfoNs   = "FileInfoNs"
	ShareIDNs    = "ShareIDNs"

	KeyInitTime = "keyInitTime"

	AdminRole   = "admin"
	UserRole    = "user"
	VisitorRole = "visitor"
)

Variables

View Source
var (
	ErrInvalidFileInfo    = errors.New("invalid fileInfo")
	ErrInvalidUser        = errors.New("invalid user")
	ErrInvalidQuota       = errors.New("invalid quota")
	ErrInvalidPreferences = errors.New("invalid preferences")
	ErrBucketNotFound     = errors.New("bucket not found")
	ErrKeyNotFound        = errors.New("key not found")
	ErrKeyExisting        = errors.New("key is existing")
	ErrCreateExisting     = errors.New("create upload info which already exists")
	ErrQuota              = errors.New("quota limit reached")

	DefaultSiteName = "Quickshare"
	DefaultSiteDesc = "Quickshare"
	DefaultBgConfig = &BgConfig{
		Url:      "",
		Repeat:   "repeat",
		Position: "top",
		Align:    "fixed",
		BgColor:  "",
	}
	DefaultAllowSetBg = false
	DefaultAutoTheme  = true
	BgRepeatValues    = map[string]bool{
		"repeat-x":  true,
		"repeat-y":  true,
		"repeat":    true,
		"space":     true,
		"round":     true,
		"no-repeat": true,
	}
	BgAlignValues = map[string]bool{
		"scroll": true,
		"fixed":  true,
		"local":  true,
	}
	BgPositionValues = map[string]bool{
		"top":    true,
		"bottom": true,
		"left":   true,
		"right":  true,
		"center": true,
	}

	DefaultCSSURL     = ""
	DefaultLanPackURL = ""
	DefaultLan        = "en_US"
	DefaultTheme      = "light"
	DefaultAvatar     = ""
	DefaultEmail      = ""

	DefaultSpaceLimit         = int64(1024 * 1024 * 1024) // 1GB
	DefaultUploadSpeedLimit   = 50 * 1024 * 1024          // 50MB
	DefaultDownloadSpeedLimit = 50 * 1024 * 1024          // 50MB
	VisitorUploadSpeedLimit   = 10 * 1024 * 1024          // 10MB
	VisitorDownloadSpeedLimit = 10 * 1024 * 1024          // 10MB

	DefaultPreferences = Preferences{
		Bg:         DefaultBgConfig,
		CSSURL:     DefaultCSSURL,
		LanPackURL: DefaultLanPackURL,
		Lan:        DefaultLan,
		Theme:      DefaultTheme,
		Avatar:     DefaultAvatar,
		Email:      DefaultEmail,
	}
)

Functions

func CheckBgConfig added in v0.8.1

func CheckBgConfig(cfg *BgConfig, fillDefault bool) error

func CheckFileInfo added in v0.8.1

func CheckFileInfo(info *FileInfo, fillDefault bool) error

TODO: auto trigger hash generating

func CheckPreferences added in v0.8.1

func CheckPreferences(prefers *Preferences, fillDefault bool) error

func CheckQuota added in v0.8.1

func CheckQuota(quota *Quota) error

TODO: check upper and lower limit

func CheckSiteCfg added in v0.8.1

func CheckSiteCfg(cfg *SiteConfig, fillDefault bool) error

func CheckUser added in v0.8.1

func CheckUser(user *User, fillDefault bool) error

func ComparePreferences added in v0.7.1

func ComparePreferences(p1, p2 *Preferences) bool

func UploadNS

func UploadNS(user string) string

Types

type BgConfig added in v0.8.1

type BgConfig struct {
	Url      string `json:"url" yaml:"url"`
	Repeat   string `json:"repeat" yaml:"repeat"`
	Position string `json:"position" yaml:"position"`
	Align    string `json:"align" yaml:"align"`
	BgColor  string `json:"bgColor" yaml:"bgColor"`
}

type ClientConfig added in v0.8.1

type ClientConfig struct {
	SiteName   string    `json:"siteName" yaml:"siteName"`
	SiteDesc   string    `json:"siteDesc" yaml:"siteDesc"`
	Bg         *BgConfig `json:"bg" yaml:"bg"`
	AllowSetBg bool      `json:"allowSetBg" yaml:"allowSetBg"`
	AutoTheme  bool      `json:"autoTheme" yaml:"autoTheme"`
}

type FileInfo

type FileInfo struct {
	IsDir   bool   `json:"isDir" yaml:"isDir"`
	Shared  bool   `json:"shared" yaml:"shared"`
	ShareID string `json:"shareID" yaml:"shareID"`
	Sha1    string `json:"sha1" yaml:"sha1"`
	Size    int64  `json:"size" yaml:"size"`
}

type Preferences

type Preferences struct {
	Bg         *BgConfig `json:"bg" yaml:"bg"`
	CSSURL     string    `json:"cssURL" yaml:"cssURL"`
	LanPackURL string    `json:"lanPackURL" yaml:"lanPackURL"`
	Lan        string    `json:"lan" yaml:"lan"`
	Theme      string    `json:"theme" yaml:"theme"`
	Avatar     string    `json:"avatar" yaml:"avatar"`
	Email      string    `json:"email" yaml:"email"`
}

type Quota

type Quota struct {
	SpaceLimit         int64 `json:"spaceLimit,string" yaml:"spaceLimit,string"`
	UploadSpeedLimit   int   `json:"uploadSpeedLimit" yaml:"uploadSpeedLimit"`
	DownloadSpeedLimit int   `json:"downloadSpeedLimit" yaml:"downloadSpeedLimit"`
}

type SiteConfig added in v0.8.1

type SiteConfig struct {
	ClientCfg *ClientConfig `json:"clientCfg" yaml:"clientCfg"`
}

type UploadInfo

type UploadInfo struct {
	RealFilePath string `json:"realFilePath" yaml:"realFilePath"`
	Size         int64  `json:"size" yaml:"size"`
	Uploaded     int64  `json:"uploaded" yaml:"uploaded"`
}

type User

type User struct {
	ID          uint64       `json:"id,string" yaml:"id,string"`
	Name        string       `json:"name" yaml:"name"`
	Pwd         string       `json:"pwd" yaml:"pwd"`
	Role        string       `json:"role" yaml:"role"`
	UsedSpace   int64        `json:"usedSpace,string" yaml:"usedSpace,string"`
	Quota       *Quota       `json:"quota" yaml:"quota"`
	Preferences *Preferences `json:"preferences" yaml:"preferences"`
}

type UserCfg added in v0.8.1

type UserCfg struct {
	Name string `json:"name" yaml:"name"`
	Role string `json:"role" yaml:"role"`
	Pwd  string `json:"pwd" yaml:"pwd"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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