model

package
v4.2.8 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Locked   = NoRename | NoRemove | NoMove
	ReadOnly = Locked | NoWrite // NoRename | NoDelete | NoMove | NoWrite
)
View Source
const (
	SINGLE = iota
	SITE
	STYLE
	PREVIEW
	GLOBAL
	OFFLINE_DOWNLOAD
	INDEX
	SSO
	LDAP
	S3
	FTP
	TRAFFIC
	MEDIA
	TRANSCODE
)
View Source
const (
	PUBLIC = iota
	PRIVATE
	READONLY
	DEPRECATED
)
View Source
const (
	GENERAL = iota
	GUEST   // only one exists
	ADMIN
)
View Source
const (
	StaticHashSalt = "https://github.com/alist-org/alist"

	InvalidUsernameOrPassword = "Invalid username or password"
	Invalid2FACode            = "Invalid 2FA code"
	TooManyAttempts           = "Too many unsuccessful sign-in attempts have been made using an incorrect username or password, Try again later."
	GuestCannotUpdateProfile  = "Guest user can not update profile"
	GuestCannotGenerate2FA    = "Guest user can not generate 2FA code"
)
View Source
const MaxInt = int(MaxUint >> 1)
View Source
const MaxUint = ^uint(0)
View Source
const MediaIndexColumnMax = 191

MediaIndexColumnMax 复合唯一索引列(folder_path / file_name / album_name)的最大字符数

View Source
const MinInt = -MaxInt - 1
View Source
const MinUint = 0

Variables

View Source
var (
	DefaultLockDuration   = time.Minute * 5
	DefaultMaxAuthRetries = 5
)
View Source
var LoginCache = cache.NewMemCache[int]()

Functions

func CanAccessWithoutPassword added in v4.1.9

func CanAccessWithoutPassword(permission int32) bool

func CanAddOfflineDownloadTasks added in v4.1.9

func CanAddOfflineDownloadTasks(permission int32) bool

func CanCopy added in v4.1.9

func CanCopy(permission int32) bool

func CanCustomizeShareID added in v4.2.2

func CanCustomizeShareID(permission int32) bool

func CanDecompress added in v4.1.9

func CanDecompress(permission int32) bool

func CanFTPAccess added in v4.1.9

func CanFTPAccess(permission int32) bool

func CanFTPManage added in v4.1.9

func CanFTPManage(permission int32) bool

func CanMove added in v4.1.9

func CanMove(permission int32) bool

func CanReadArchives added in v4.1.9

func CanReadArchives(permission int32) bool

func CanRemove added in v4.1.9

func CanRemove(permission int32) bool

func CanRename added in v4.1.9

func CanRename(permission int32) bool

func CanSeeHides added in v4.1.9

func CanSeeHides(permission int32) bool

func CanShare added in v4.1.9

func CanShare(permission int32) bool

func CanWebdavManage added in v4.1.9

func CanWebdavManage(permission int32) bool

func CanWebdavRead added in v4.1.9

func CanWebdavRead(permission int32) bool

func CanWriteContent added in v4.2.0

func CanWriteContent(permission int32) bool

func ExtractFolder

func ExtractFolder(objs []Obj, extractFolder string)

func GetProvider added in v4.1.3

func GetProvider(obj Obj) (string, bool)

func GetThumb

func GetThumb(obj Obj) (thumb string, ok bool)

func GetUrl

func GetUrl(obj Obj) (url string, ok bool)

func HashPwd

func HashPwd(static string, salt string) string

func ObjHasMask added in v4.1.9

func ObjHasMask(obj Obj, mask ObjMask) bool

func SortFiles

func SortFiles(objs []Obj, orderBy, orderDirection string)

func StaticHash

func StaticHash(password string) string

func TwoHashPwd

func TwoHashPwd(password string, salt string) string

func WrapObjsName

func WrapObjsName(objs []Obj)

Types

type ArchiveArgs

type ArchiveArgs struct {
	Password string
	LinkArgs
}

type ArchiveDecompressArgs

type ArchiveDecompressArgs struct {
	ArchiveInnerArgs
	CacheFull     bool
	PutIntoNewDir bool
	Overwrite     bool
}

type ArchiveInnerArgs

type ArchiveInnerArgs struct {
	ArchiveArgs
	InnerPath string
}

type ArchiveListArgs

type ArchiveListArgs struct {
	ArchiveInnerArgs
	Refresh bool
}

type ArchiveMeta

type ArchiveMeta interface {
	GetComment() string
	// IsEncrypted means if the content of the archive requires a password to access
	// GetArchiveMeta should return errs.WrongArchivePassword if the meta-info is also encrypted,
	// and the provided password is empty.
	IsEncrypted() bool
	// GetTree directly returns the full folder structure
	// returns nil if the folder structure should be acquired by calling driver.ArchiveReader.ListArchive
	GetTree() []ObjTree
}

type ArchiveMetaArgs

type ArchiveMetaArgs struct {
	ArchiveArgs
	Refresh bool
}

type ArchiveMetaInfo

type ArchiveMetaInfo struct {
	Comment   string
	Encrypted bool
	Tree      []ObjTree
}

func (*ArchiveMetaInfo) GetComment

func (m *ArchiveMetaInfo) GetComment() string

func (*ArchiveMetaInfo) GetTree

func (m *ArchiveMetaInfo) GetTree() []ObjTree

func (*ArchiveMetaInfo) IsEncrypted

func (m *ArchiveMetaInfo) IsEncrypted() bool

type ArchiveMetaProvider

type ArchiveMetaProvider struct {
	ArchiveMeta
	*Sort
	DriverProviding bool
	Expiration      *time.Duration
}

type DiskUsage added in v4.1.4

type DiskUsage struct {
	TotalSpace int64
	UsedSpace  int64
}

func (DiskUsage) FreeSpace added in v4.1.4

func (d DiskUsage) FreeSpace() int64

func (DiskUsage) MarshalJSON added in v4.1.10

func (d DiskUsage) MarshalJSON() ([]byte, error)

type EmbyDevice added in v4.2.8

type EmbyDevice struct {
	ID        uint      `gorm:"primarykey"             json:"id"`
	CreatedAt time.Time `json:"created_at"`

	UserID     uint      `gorm:"index;not null"        json:"user_id"`
	DeviceID   string    `json:"device_id"` // 客户端上报的 DeviceId
	DeviceName string    `json:"device_name"`
	Client     string    `json:"client"`
	Version    string    `json:"version"`
	TokenHash  string    `gorm:"uniqueIndex;not null"  json:"-"`
	AppKeyID   uint      `json:"app_key_id"` // 通过应用密钥认证时为对应 key,否则为 0
	LastSeenAt time.Time `json:"last_seen_at"`
}

EmbyDevice Emby 客户端会话(由 AuthenticateByName 签发)

type EpisodeInfo added in v4.2.8

type EpisodeInfo struct {
	FileName string `json:"file_name"` // 原始文件名(含扩展名)
	Index    int    `json:"index"`     // 序号,默认0,文件名开头有数字则取该数字
	Title    string `json:"title"`     // 选集标题(去掉序号后的文件名,不含扩展名)
}

EpisodeInfo 选集信息(文件夹型媒体的单集描述)

type File

type File interface {
	io.ReaderAt
	io.ReadSeeker
}

File is basic file level accessing interface

type FileCloser added in v4.0.9

type FileCloser struct {
	File
	io.Closer
}

func (*FileCloser) Close added in v4.0.9

func (f *FileCloser) Close() (err error)

type FileRangeReader added in v4.0.9

type FileRangeReader struct {
	RangeReaderIF
}

FileRangeReader 是对 RangeReaderIF 的轻量包装,表明由 RangeReaderIF.RangeRead 返回的 io.ReadCloser 同时实现了 model.File(即支持 Read/ReadAt/Seek)。 只有满足这些才需要使用 FileRangeReader,否则直接使用 RangeReaderIF 即可。

type FileStreamer

type FileStreamer interface {
	io.Reader
	utils.ClosersIF
	Obj
	GetMimetype() string
	NeedStore() bool
	IsForceStreamUpload() bool
	GetExist() Obj
	SetExist(Obj)
	// for a non-seekable Stream, RangeRead supports peeking some data, and CacheFullAndWriter still works
	RangeRead(http_range.Range) (io.Reader, error)
	// for a non-seekable Stream, if Read is called, this function won't work.
	// caches the full Stream and writes it to writer (if provided, even if the stream is already cached).
	CacheFullAndWriter(up *UpdateProgress, writer io.Writer) (File, error)
	// if the Stream is not a File and is not cached, returns nil.
	GetFile() File
}

FileStreamer ->check FileStream for more comments

type FileWriter added in v4.2.2

type FileWriter interface {
	io.WriterAt
	io.WriteSeeker
}

type FsOtherArgs

type FsOtherArgs struct {
	Path   string      `json:"path" form:"path"`
	Method string      `json:"method" form:"method"`
	Data   interface{} `json:"data" form:"data"`
}

type HttpDirectUploadInfo added in v4.1.7

type HttpDirectUploadInfo struct {
	UploadURL string            `json:"upload_url"`        // The URL to upload the file
	ChunkSize int64             `json:"chunk_size"`        // The chunk size for uploading, 0 means no chunking required
	Headers   map[string]string `json:"headers,omitempty"` // Optional headers to include in the upload request
	Method    string            `json:"method,omitempty"`  // HTTP method, default is PUT
}

type IndexProgress

type IndexProgress struct {
	ObjCount     uint64     `json:"obj_count"`
	IsDone       bool       `json:"is_done"`
	LastDoneTime *time.Time `json:"last_done_time"`
	Error        string     `json:"error"`
}
type Link struct {
	URL         string        `json:"url"`    // most common way
	Header      http.Header   `json:"header"` // needed header (for url)
	RangeReader RangeReaderIF `json:"-"`      // recommended way if can't use URL

	Expiration *time.Duration // local cache expiration; not transferred by Clone

	//for accelerating request, use multi-thread downloading
	Concurrency   int   `json:"concurrency"`
	PartSize      int   `json:"part_size"`
	ContentLength int64 `json:"content_length"` // 转码视频、缩略图

	utils.SyncClosers `json:"-"`
	// 如果SyncClosers中的资源被关闭后Link将不可用,则此值应为 true
	RequireReference bool `json:"-"`
}

func (*Link) Clone added in v4.2.3

func (l *Link) Clone() *Link

Clone transfers ownership of l without inheriting its cache expiration.

type LinkArgs

type LinkArgs struct {
	IP       string
	Header   http.Header
	Type     string
	Redirect bool
}

type ListArgs

type ListArgs struct {
	ReqPath            string
	S3ShowPlaceholder  bool
	Refresh            bool
	WithStorageDetails bool
	SkipHook           bool
}

type MediaAnnotation added in v4.2.8

type MediaAnnotation struct {
	ID        uint      `gorm:"primarykey"                    json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	UserID uint `gorm:"uniqueIndex:idx_media_annotation_key;not null"       json:"-"`
	ItemID uint `gorm:"uniqueIndex:idx_media_annotation_key;not null;index" json:"item_id"`
	// RemoteID 是查看器分配的批注 id:多设备打开同一份 PDF 时靠它做去重与更新
	RemoteID string `gorm:"uniqueIndex:idx_media_annotation_key;size:128;not null" json:"remote_id"`
	Anchor   string `gorm:"type:text;not null"                                json:"anchor"`
}

MediaAnnotation 用户在 PDF 阅读器里添加的批注。

只存查看器原生的批注对象(Anchor,JSON):页码、rect/quadPoints、颜色、 文字、绘制点集都在里面,拆成独立列会出现两份可能不一致的数据。 重新打开时原样回灌给 PDF 引擎,因此这里不重复建模。

type MediaAppKey added in v4.2.8

type MediaAppKey struct {
	ID        uint      `gorm:"primarykey"                  json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	UserID uint   `gorm:"index;not null"       json:"user_id"`
	Name   string `json:"name"`                               // 备注名,例如 "Symfonium"、"MoviePilot"
	Prefix string `gorm:"index"                json:"prefix"` // 明文前缀(便于识别/排查)
	Secret string `gorm:"not null"             json:"-"`      // AES-GCM 密文(base64)

	LastUsedAt *time.Time `json:"last_used_at"`
}

MediaAppKey 媒体应用密钥。 用于无法走交互式登录的客户端(Subsonic 的 token 认证、Emby 的 api_key、 MoviePilot 对接等)。密钥本身以 AES-GCM 加密存储,数据库中不保留明文。

type MediaConfig added in v4.2.8

type MediaConfig struct {
	gorm.Model
	ID           uint           `gorm:"primarykey"           json:"id"`
	CreatedAt    time.Time      `json:"created_at"`
	UpdatedAt    time.Time      `json:"updated_at"`
	DeletedAt    gorm.DeletedAt `gorm:"index"                json:"-"`
	MediaType    MediaType      `gorm:"uniqueIndex;not null" json:"media_type"`
	Enabled      bool           `gorm:"default:false"        json:"enabled"`
	LastScanAt   *time.Time     `json:"last_scan_at"`
	LastScrapeAt *time.Time     `json:"last_scrape_at"`
	// ScraperConfig 该媒体类型独立的刮削配置(JSON):
	// store_thumbnail / thumbnail_mode / thumbnail_path,未设置时回落到全局设置
	ScraperConfig string `gorm:"type:text" json:"scraper_config"`
}

MediaConfig 媒体库配置(每种类型一条记录)

type MediaItem added in v4.2.8

type MediaItem struct {
	gorm.Model
	// 覆盖 gorm.Model 的 ID 字段,使 JSON 序列化为小写 "id",与前端保持一致
	ID        uint           `gorm:"primarykey"           json:"id"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index"                json:"-"`
	// 基础信息
	MediaType  MediaType `gorm:"index;not null"          json:"media_type"`
	ScanPathID uint      `gorm:"index"                   json:"scan_path_id"` // 关联的扫描路径ID
	// 三个字段共同组成复合唯一索引。MySQL 对「有索引且未指定长度」的 string 会生成 longtext,
	// 而 TEXT 列不能直接建索引(AutoMigrate 会失败);因此必须显式限定 size。
	// utf8mb4 下 InnoDB 索引总长上限 3072 字节:191*3*4 = 2292,留足余量。
	FileName string `gorm:"size:191;uniqueIndex:idx_media_folder_file_album" json:"file_name"`
	FileSize int64  `json:"file_size"`
	MimeType string `json:"mime_type"`
	Hidden   bool   `gorm:"default:false"           json:"hidden"`

	// 刮削/编辑信息
	ScrapedName string  `json:"scraped_name"`
	Description string  `gorm:"type:text"               json:"description"`
	Cover       string  `json:"cover"`                                  // 封面URL或本地路径
	ReleaseDate string  `json:"release_date"`                           // 发布时间,格式 YYYY-MM-DD
	Rating      float32 `json:"rating"`                                 // 评分 0-10
	Genre       string  `json:"genre"`                                  // 类型,逗号分隔,如 "动作,科幻"
	Authors     string  `gorm:"type:text"               json:"authors"` // 作者/演员,JSON数组字符串
	Plot        string  `gorm:"type:text"               json:"plot"`    // 剧情/内容介绍
	Reviews     string  `gorm:"type:text"               json:"reviews"` // 用户评价,JSON数组字符串

	// 外部ID(用于刮削关联)
	ExternalID string `json:"external_id"` // TMDB ID / Discogs ID / 豆瓣ID

	// 音乐专属字段
	AlbumName   string `gorm:"size:191;uniqueIndex:idx_media_folder_file_album" json:"album_name"` // 所属专辑名
	AlbumArtist string `json:"album_artist"`                                                       // 专辑艺术家
	TrackNumber int    `json:"track_number"`                                                       // 曲目编号
	Duration    int    `json:"duration"`                                                           // 时长(秒)
	Lyrics      string `gorm:"type:text"    json:"lyrics"`                                         // LRC格式歌词

	// 视频专属字段
	VideoType string `json:"video_type"` // "movie" 或 "tv"
	Season    int    `json:"season"`     // 季(电视剧)
	Episode   int    `json:"episode"`    // 集(电视剧)

	// 书籍专属字段
	Publisher string `json:"publisher"` // 出版社
	ISBN      string `json:"isbn"`      // ISBN

	// 目录合并模式
	IsFolder   bool   `gorm:"default:false"                                    json:"is_folder"`         // 是否为文件夹模式条目
	FolderPath string `gorm:"size:191;index;uniqueIndex:idx_media_folder_file_album" json:"folder_path"` // 扫描根路径(恒定为扫描路径,与file_name+album_name组合唯一)
	Episodes   string `gorm:"type:text"                                         json:"episodes"`         // 选集信息,JSON数组,格式:[{file_name,index,title},...]

	ScrapedAt *time.Time `json:"scraped_at"`
}

MediaItem 媒体条目(统一表,通过 media_type 区分类型,便于后期扩展新类型)

type MediaPlaylist added in v4.2.8

type MediaPlaylist struct {
	ID        uint      `gorm:"primarykey"                       json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	UserID    uint   `gorm:"index;not null"           json:"user_id"`
	Name      string `json:"name"`
	Comment   string `json:"comment"`
	Public    bool   `json:"public"`
	ItemCount int    `json:"item_count"`
}

MediaPlaylist 用户播放列表(Subsonic 需要,Emby 的 Playlist 复用同一份数据)

type MediaPlaylistItem added in v4.2.8

type MediaPlaylistItem struct {
	ID           uint `gorm:"primarykey"                    json:"id"`
	PlaylistID   uint `gorm:"index;not null"                json:"playlist_id"`
	ItemID       uint `gorm:"index;not null"                json:"item_id"`
	EpisodeIndex int  `json:"episode_index"`
	Order        int  `gorm:"column:sort_order"             json:"order"`
}

MediaPlaylistItem 播放列表条目(按 Order 排序)

type MediaScanPath added in v4.2.8

type MediaScanPath struct {
	gorm.Model
	ID        uint           `gorm:"primarykey"           json:"id"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index"                json:"-"`

	MediaType    MediaType  `gorm:"index;not null"       json:"media_type"`    // 所属媒体类型
	Name         string     `json:"name"`                                      // 路径名称(用于前端筛选显示)
	Path         string     `gorm:"not null"             json:"path"`          // VFS 扫描路径
	PathMerge    bool       `gorm:"default:false"        json:"path_merge"`    // 路径合并模式(子文件夹作为一个条目)
	TypeTag      string     `json:"type_tag"`                                  // 类型标签:电影、电视剧等
	ContentTags  string     `json:"content_tags"`                              // 内容标签:喜剧、惊悚等(逗号分隔)
	EnableScrape bool       `gorm:"default:true"         json:"enable_scrape"` // 是否启用刮削
	LastScanAt   *time.Time `json:"last_scan_at"`                              // 最后扫描时间
}

MediaScanPath 媒体库扫描路径(每个媒体库可配置多个扫描路径)

type MediaScanProgress added in v4.2.8

type MediaScanProgress struct {
	MediaType  MediaType `json:"media_type"`
	ScanPathID uint      `json:"scan_path_id,omitempty"` // 0 表示全部路径
	Running    bool      `json:"running"`
	Total      int       `json:"total"`
	Done       int       `json:"done"`
	Message    string    `json:"message"`
	Error      string    `json:"error,omitempty"`
}

MediaScanProgress 扫描进度(内存中维护,不持久化)

type MediaType added in v4.2.8

type MediaType string

MediaType 媒体类型,使用字符串便于后期扩展

const (
	MediaTypeVideo MediaType = "video"
	MediaTypeMusic MediaType = "music"
	MediaTypeImage MediaType = "image"
	MediaTypeBook  MediaType = "book"
)

type MediaUserData added in v4.2.8

type MediaUserData struct {
	ID        uint      `gorm:"primarykey"                                  json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	UserID       uint `gorm:"uniqueIndex:idx_media_user_item_ep;not null"   json:"user_id"`
	ItemID       uint `gorm:"uniqueIndex:idx_media_user_item_ep;not null"   json:"item_id"`
	EpisodeIndex int  `gorm:"uniqueIndex:idx_media_user_item_ep;not null"   json:"episode_index"` // 0 表示条目本身,>0 表示选集序号

	Played        bool       `json:"played"`
	PlayCount     int        `json:"play_count"`
	IsFavorite    bool       `gorm:"index"                                  json:"is_favorite"`
	Rating        int        `json:"rating"`         // 0-5,Subsonic 语义
	PositionTicks int64      `json:"position_ticks"` // 100ns tick,与 Emby 一致
	LastPlayedAt  *time.Time `json:"last_played_at"`
}

MediaUserData 用户对媒体条目的播放状态,Emby 与 Subsonic 共用。

type Meta

type Meta struct {
	ID            uint   `json:"id" gorm:"primaryKey"`
	Path          string `json:"path" gorm:"unique" binding:"required"`
	ReadUsers     []uint `json:"read_users" gorm:"serializer:json"`
	ReadUsersSub  bool   `json:"read_users_sub"`
	WriteUsers    []uint `json:"write_users" gorm:"serializer:json"`
	WriteUsersSub bool   `json:"write_users_sub"`
	Password      string `json:"password"`
	PSub          bool   `json:"p_sub"`
	Write         bool   `json:"write"`
	WSub          bool   `json:"w_sub"`
	Hide          string `json:"hide"`
	HSub          bool   `json:"h_sub"`
	Readme        string `json:"readme"`
	RSub          bool   `json:"r_sub"`
	Header        string `json:"header"`
	HeaderSub     bool   `json:"header_sub"`
}

type Obj

type Obj interface {
	GetSize() int64
	GetName() string
	ModTime() time.Time
	CreateTime() time.Time
	IsDir() bool
	GetHash() utils.HashInfo

	// The internal information of the driver.
	// If you want to use it, please understand what it means
	GetID() string
	GetPath() string
}

func UnwrapObjName added in v4.1.9

func UnwrapObjName(obj Obj) Obj

func WrapObjName

func WrapObjName(obj Obj) Obj

type ObjDisplayName added in v4.2.6

type ObjDisplayName interface {
	GetDisplayName() string
}

type ObjMask added in v4.1.9

type ObjMask uint8
const (
	Virtual ObjMask = 1 << iota
	NoRename
	NoRemove
	NoMove
	NoCopy
	NoWrite
	Temp
)

func GetObjMask added in v4.1.9

func GetObjMask(obj Obj) ObjMask

func (ObjMask) GetObjMask added in v4.1.9

func (m ObjMask) GetObjMask() ObjMask

type ObjMerge

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

func NewObjMerge

func NewObjMerge() *ObjMerge

Merge

func (*ObjMerge) InitHideReg

func (om *ObjMerge) InitHideReg(hides string)

func (*ObjMerge) Merge

func (om *ObjMerge) Merge(objs []Obj, objs_ ...Obj) []Obj

func (*ObjMerge) Reset

func (om *ObjMerge) Reset()

type ObjStorageDetails added in v4.1.4

type ObjStorageDetails struct {
	Obj
	*StorageDetails
}

func (*ObjStorageDetails) GetStorageDetails added in v4.1.4

func (o *ObjStorageDetails) GetStorageDetails() *StorageDetails

func (*ObjStorageDetails) Unwrap added in v4.1.9

func (o *ObjStorageDetails) Unwrap() Obj

type ObjThumb

type ObjThumb struct {
	Object
	Thumbnail
}

type ObjThumbURL

type ObjThumbURL struct {
	Object
	Thumbnail
	Url
}

type ObjTree

type ObjTree interface {
	Obj
	GetChildren() []ObjTree
}

type ObjUnwrap

type ObjUnwrap interface {
	Unwrap() Obj
}

type ObjWithProvider added in v4.1.3

type ObjWithProvider interface {
	GetProvider() string
}

type ObjWithStorageDetails added in v4.1.4

type ObjWithStorageDetails interface {
	GetStorageDetails() *StorageDetails
}

type ObjWrapMask added in v4.1.9

type ObjWrapMask struct {
	Obj
	Mask ObjMask
}

func (*ObjWrapMask) GetObjMask added in v4.1.9

func (m *ObjWrapMask) GetObjMask() ObjMask

func (*ObjWrapMask) Unwrap added in v4.1.9

func (m *ObjWrapMask) Unwrap() Obj

type ObjWrapName

type ObjWrapName struct {
	Name string
	Obj
}

func (*ObjWrapName) GetName

func (o *ObjWrapName) GetName() string

func (*ObjWrapName) Unwrap

func (o *ObjWrapName) Unwrap() Obj

type Object

type Object struct {
	ID       string
	Path     string
	Name     string
	Size     int64
	Modified time.Time
	Ctime    time.Time // file create time
	IsFolder bool
	HashInfo utils.HashInfo
	Mask     ObjMask
}

func (*Object) CreateTime

func (o *Object) CreateTime() time.Time

func (*Object) GetHash

func (o *Object) GetHash() utils.HashInfo

func (*Object) GetID

func (o *Object) GetID() string

func (*Object) GetName

func (o *Object) GetName() string

func (*Object) GetObjMask added in v4.1.9

func (o *Object) GetObjMask() ObjMask

func (*Object) GetPath

func (o *Object) GetPath() string

func (*Object) GetSize

func (o *Object) GetSize() int64

func (*Object) IsDir

func (o *Object) IsDir() bool

func (*Object) ModTime

func (o *Object) ModTime() time.Time

func (*Object) SetPath

func (o *Object) SetPath(path string)

type ObjectProvider added in v4.1.3

type ObjectProvider struct {
	Object
	Provider
}

type ObjectTree

type ObjectTree struct {
	Object
	Children []ObjTree
}

func (*ObjectTree) GetChildren

func (t *ObjectTree) GetChildren() []ObjTree

type ObjectURL

type ObjectURL struct {
	Object
	Url
}

type OtherArgs

type OtherArgs struct {
	Obj    Obj
	Method string
	Data   interface{}
}

type PageReq

type PageReq struct {
	Page    int `json:"page" form:"page"`
	PerPage int `json:"per_page" form:"per_page"`
}

func (*PageReq) Validate

func (p *PageReq) Validate()

type Provider added in v4.1.3

type Provider struct {
	Provider string
}

func (Provider) GetProvider added in v4.1.3

func (p Provider) GetProvider() string

type Proxy

type Proxy struct {
	WebProxy     bool   `json:"web_proxy"`
	WebdavPolicy string `json:"webdav_policy"`
	ProxyRange   bool   `json:"proxy_range"`
	DownProxyURL string `json:"down_proxy_url"`
	// Disable sign for DownProxyURL
	DisableProxySign bool `json:"disable_proxy_sign"`
}

func (Proxy) Webdav302

func (p Proxy) Webdav302() bool

func (Proxy) WebdavProxyURL added in v4.0.9

func (p Proxy) WebdavProxyURL() bool

type RangeReaderIF added in v4.0.9

type RangeReaderIF interface {
	RangeRead(ctx context.Context, httpRange http_range.Range) (io.ReadCloser, error)
}

type SSHPublicKey

type SSHPublicKey struct {
	ID           uint      `json:"id" gorm:"primaryKey"`
	UserId       uint      `json:"-"`
	Title        string    `json:"title"`
	Fingerprint  string    `json:"fingerprint"`
	KeyStr       string    `gorm:"type:text" json:"-"`
	AddedTime    time.Time `json:"added_time"`
	LastUsedTime time.Time `json:"last_used_time"`
}

func (*SSHPublicKey) GetKey

func (k *SSHPublicKey) GetKey() (ssh.PublicKey, error)

func (*SSHPublicKey) UpdateLastUsedTime

func (k *SSHPublicKey) UpdateLastUsedTime()

type SearchNode

type SearchNode struct {
	Parent string `json:"parent" gorm:"index"`
	Name   string `json:"name"`
	IsDir  bool   `json:"is_dir"`
	Size   int64  `json:"size"`
}

func (*SearchNode) Type

func (s *SearchNode) Type() string

type SearchReq

type SearchReq struct {
	Parent   string `json:"parent"`
	Keywords string `json:"keywords"`
	// 0 for all, 1 for dir, 2 for file
	Scope int `json:"scope"`
	PageReq
}

func (*SearchReq) Validate

func (p *SearchReq) Validate() error

type SetPath

type SetPath interface {
	SetPath(path string)
}

type SettingItem

type SettingItem struct {
	Key            string `json:"key" gorm:"primaryKey" binding:"required"` // unique key
	Value          string `json:"value"`                                    // value
	MigrationValue string `json:"-" gorm:"-:all"`                           // deprecated value
	Help           string `json:"help"`                                     // help message
	Type           string `json:"type"`                                     // string, number, bool, select
	Options        string `json:"options"`                                  // values for select
	Group          int    `json:"group"`                                    // use to group setting in frontend
	Flag           int    `json:"flag"`                                     // 0 = public, 1 = private, 2 = readonly, 3 = deprecated, etc.
	Index          uint   `json:"index"`
}

func (SettingItem) IsDeprecated

func (s SettingItem) IsDeprecated() bool

type Sharing added in v4.1.2

type Sharing struct {
	*SharingDB
	Files   []string `json:"files"`
	Creator *User    `json:"-"`
}

func (*Sharing) Valid added in v4.1.2

func (s *Sharing) Valid() bool

func (*Sharing) Verify added in v4.1.2

func (s *Sharing) Verify(pwd string) bool

type SharingArchiveListArgs added in v4.1.2

type SharingArchiveListArgs struct {
	ArchiveListArgs
	Pwd string
}

type SharingArchiveMetaArgs added in v4.1.2

type SharingArchiveMetaArgs struct {
	ArchiveMetaArgs
	Pwd string
}

type SharingDB added in v4.1.2

type SharingDB struct {
	ID          string     `json:"id" gorm:"type:varchar(64);primaryKey"`
	FilesRaw    string     `json:"-" gorm:"type:text"`
	Expires     *time.Time `json:"expires"`
	Pwd         string     `json:"pwd"`
	Accessed    int        `json:"accessed"`
	MaxAccessed int        `json:"max_accessed"`
	CreatorId   uint       `json:"-"`
	Disabled    bool       `json:"disabled"`
	Remark      string     `json:"remark"`
	Readme      string     `json:"readme" gorm:"type:text"`
	Header      string     `json:"header" gorm:"type:text"`
	Sort
}

type SharingLinkArgs added in v4.1.2

type SharingLinkArgs struct {
	Pwd string
	LinkArgs
}

type SharingListArgs added in v4.1.2

type SharingListArgs struct {
	Refresh bool
	Pwd     string
}

type Sort

type Sort struct {
	OrderBy        string `json:"order_by"`
	OrderDirection string `json:"order_direction"`
	ExtractFolder  string `json:"extract_folder"`
}

type Storage

type Storage struct {
	ID                  uint      `json:"id" gorm:"primaryKey"`                        // unique key
	MountPath           string    `json:"mount_path" gorm:"unique" binding:"required"` // must be standardized
	Order               int       `json:"order"`                                       // use to sort
	Driver              string    `json:"driver"`                                      // driver used
	CacheExpiration     int       `json:"cache_expiration"`                            // cache expire time
	CustomCachePolicies string    `json:"custom_cache_policies" gorm:"type:text"`
	Status              string    `json:"status"`
	Addition            string    `json:"addition" gorm:"type:text"` // Additional information, defined in the corresponding driver
	Remark              string    `json:"remark"`
	Modified            time.Time `json:"modified"`
	Disabled            bool      `json:"disabled"` // if disabled
	DisableIndex        bool      `json:"disable_index"`
	EnableSign          bool      `json:"enable_sign"`
	SeedPolicy          string    `json:"seed_policy" gorm:"default:inherit"`
	Sort
	Proxy
}

func (*Storage) GetStorage

func (s *Storage) GetStorage() *Storage

func (*Storage) SetStatus

func (s *Storage) SetStatus(status string)

func (*Storage) SetStorage

func (s *Storage) SetStorage(storage Storage)

type StorageDetails added in v4.1.4

type StorageDetails struct {
	DiskUsage
}

func GetStorageDetails added in v4.1.4

func GetStorageDetails(obj Obj) (*StorageDetails, bool)

type TaskItem

type TaskItem struct {
	Key         string `json:"key"`
	PersistData string `gorm:"type:text" json:"persist_data"`
}

type Thumb

type Thumb interface {
	Thumb() string
}

type Thumbnail

type Thumbnail struct {
	Thumbnail string
}

func (Thumbnail) Thumb

func (t Thumbnail) Thumb() string

type URL

type URL interface {
	URL() string
}

type UpdateProgress

type UpdateProgress func(percentage float64)

func UpdateProgressWithRange added in v4.0.9

func UpdateProgressWithRange(inner UpdateProgress, start, end float64) UpdateProgress

type Url

type Url struct {
	Url string
}

func (Url) URL

func (w Url) URL() string

type User

type User struct {
	ID       uint   `json:"id" gorm:"primaryKey"`                      // unique key
	Username string `json:"username" gorm:"unique" binding:"required"` // username
	PwdHash  string `json:"-"`                                         // password hash
	PwdTS    int64  `json:"-"`                                         // password timestamp
	Salt     string `json:"-"`                                         // unique salt
	Password string `json:"password"`                                  // password
	BasePath string `json:"base_path"`                                 // base path
	Role     int    `json:"role"`                                      // user's role
	Disabled bool   `json:"disabled"`
	// Determine permissions by bit
	//   0:  can see hidden files
	//   1:  can access without password
	//   2:  can add offline download tasks
	//   3:  can mkdir and upload
	//   4:  can rename
	//   5:  can move
	//   6:  can copy
	//   7:  can remove
	//   8:  webdav read
	//   9:  webdav write
	//   10: ftp/sftp login and read
	//   11: ftp/sftp write
	//   12: can read archives
	//   13: can decompress archives
	//   14: can share
	//   15: can customize share id
	Permission int32  `json:"permission"`
	OtpSecret  string `json:"-"`
	SsoID      string `json:"sso_id"` // unique by sso platform
	Authn      string `gorm:"type:text" json:"-"`
	AllowLdap  bool   `json:"allow_ldap" gorm:"default:true"`
}

func (*User) CanAccessWithoutPassword

func (u *User) CanAccessWithoutPassword() bool

func (*User) CanAddOfflineDownloadTasks

func (u *User) CanAddOfflineDownloadTasks() bool

func (*User) CanCopy

func (u *User) CanCopy() bool

func (*User) CanCustomizeShareID added in v4.2.2

func (u *User) CanCustomizeShareID() bool

func (*User) CanDecompress

func (u *User) CanDecompress() bool

func (*User) CanFTPAccess

func (u *User) CanFTPAccess() bool

func (*User) CanFTPManage

func (u *User) CanFTPManage() bool

func (*User) CanMove

func (u *User) CanMove() bool

func (*User) CanReadArchives

func (u *User) CanReadArchives() bool

func (*User) CanRemove

func (u *User) CanRemove() bool

func (*User) CanRename

func (u *User) CanRename() bool

func (*User) CanSeeHides

func (u *User) CanSeeHides() bool

func (*User) CanShare added in v4.1.2

func (u *User) CanShare() bool

func (*User) CanWebdavManage

func (u *User) CanWebdavManage() bool

func (*User) CanWebdavRead

func (u *User) CanWebdavRead() bool

func (*User) CanWriteContent added in v4.2.0

func (u *User) CanWriteContent() bool

func (*User) IsAdmin

func (u *User) IsAdmin() bool

func (*User) IsGuest

func (u *User) IsGuest() bool

func (*User) JoinPath

func (u *User) JoinPath(reqPath string) (string, error)

func (*User) SetPassword

func (u *User) SetPassword(pwd string) *User

func (*User) ValidatePwdStaticHash

func (u *User) ValidatePwdStaticHash(pwdStaticHash string) error

func (*User) ValidateRawPassword

func (u *User) ValidateRawPassword(password string) error

func (*User) WebAuthnCredentials

func (u *User) WebAuthnCredentials() []webauthn.Credential

func (*User) WebAuthnDisplayName

func (u *User) WebAuthnDisplayName() string

func (*User) WebAuthnID

func (u *User) WebAuthnID() []byte

func (*User) WebAuthnIcon

func (u *User) WebAuthnIcon() string

func (*User) WebAuthnName

func (u *User) WebAuthnName() string

type WebDAVProperty added in v4.2.8

type WebDAVProperty struct {
	ID        uint   `json:"id" gorm:"primaryKey"`
	Path      string `json:"path" gorm:"uniqueIndex:idx_webdav_property"`
	Namespace string `json:"namespace" gorm:"uniqueIndex:idx_webdav_property"`
	Name      string `json:"name" gorm:"uniqueIndex:idx_webdav_property"`
	Lang      string `json:"lang"`
	InnerXML  []byte `json:"inner_xml"`
}

WebDAVProperty stores a dead WebDAV property for a resource.

Jump to

Keyboard shortcuts

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