model

package
v0.4.4-alpha2 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

@Author: LinkLeong link@icewhale.com

*@Date: 2022-07-13 10:43:45
*@LastEditors: LinkLeong
*@LastEditTime: 2022-08-03 14:45:35
*@FilePath: /CasaOS/model/disk.go
*@Description:
*@Website: https://www.casaos.io
*Copyright (c) 2022 by icewhale, All Rights Reserved.

Index

Constants

View Source
const (
	SINGLE = iota
	SITE
	STYLE
	PREVIEW
	GLOBAL
	ARIA2
	INDEX
	GITHUB
)
View Source
const (
	PUBLIC = iota
	PRIVATE
	READONLY
	DEPRECATED
)

Variables

This section is empty.

Functions

func ExtractFolder added in v0.4.3

func ExtractFolder(objs []Obj, extractFolder string)

func GetThumb added in v0.4.3

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

func GetUrl added in v0.4.3

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

func SortFiles added in v0.4.3

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

func WrapObjsName added in v0.4.3

func WrapObjsName(objs []Obj)

Types

type APPModel

type APPModel struct {
	LogPath     string
	LogSaveName string
	LogFileExt  string
	ShellPath   string
	DBPath      string
}

type CommonModel

type CommonModel struct {
	RuntimePath string
}

type DFDiskSpace added in v0.4.1

type DFDiskSpace struct {
	FileSystem string
	Type       string
	Blocks     string
	Used       string
	Available  string
	UsePercent string
	MountedOn  string
}

type DiskStatus

type DiskStatus struct {
	Size   uint64 `json:"size"`
	Avail  uint64 `json:"avail"` // 可用空间
	Health bool   `json:"health"`
	Used   uint64 `json:"used"`
}

type Drive

type Drive struct {
	Name           string `json:"name"`
	Size           uint64 `json:"size"`
	Model          string `json:"model"`
	Health         string `json:"health"`
	Temperature    int    `json:"temperature"`
	DiskType       string `json:"disk_type"`
	NeedFormat     bool   `json:"need_format"`
	Serial         string `json:"serial"`
	Path           string `json:"path"`
	ChildrenNumber int    `json:"children_number"`
}

type FileStream added in v0.4.3

type FileStream struct {
	Obj
	io.ReadCloser
	Mimetype     string
	WebPutAsTask bool
	Old          Obj
}

func (*FileStream) GetMimetype added in v0.4.3

func (f *FileStream) GetMimetype() string

func (*FileStream) GetOld added in v0.4.3

func (f *FileStream) GetOld() Obj

func (*FileStream) GetReadCloser added in v0.4.3

func (f *FileStream) GetReadCloser() io.ReadCloser

func (*FileStream) NeedStore added in v0.4.3

func (f *FileStream) NeedStore() bool

func (*FileStream) SetReadCloser added in v0.4.3

func (f *FileStream) SetReadCloser(rc io.ReadCloser)

type FileStreamer added in v0.4.3

type FileStreamer interface {
	io.ReadCloser
	Obj
	GetMimetype() string
	SetReadCloser(io.ReadCloser)
	NeedStore() bool
	GetReadCloser() io.ReadCloser
	GetOld() Obj
}

type FsOtherArgs added in v0.4.3

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

type LSBLKModel

type LSBLKModel struct {
	Name        string       `json:"name"`
	FsType      string       `json:"fstype"`
	Size        uint64       `json:"size"`
	FSSize      json.Number  `json:"fssize"`
	Path        string       `json:"path"`
	Model       string       `json:"model"` // 设备标识符
	RM          bool         `json:"rm"`    // 是否为可移动设备
	RO          bool         `json:"ro"`    // 是否为只读设备
	State       string       `json:"state"`
	PhySec      int          `json:"phy-sec"` // 物理扇区大小
	Type        string       `json:"type"`
	Vendor      string       `json:"vendor"`  // 供应商
	Rev         string       `json:"rev"`     // 修订版本
	FSAvail     json.Number  `json:"fsavail"` // 可用空间
	FSUse       string       `json:"fsuse%"`  // 已用百分比
	MountPoint  string       `json:"mountpoint"`
	Format      string       `json:"format"`
	Health      string       `json:"health"`
	HotPlug     bool         `json:"hotplug"`
	UUID        string       `json:"uuid"`
	PTUUID      string       `json:"ptuuid"`
	PartUUID    string       `json:"partuuid"`
	FSUsed      json.Number  `json:"fsused"`
	Temperature int          `json:"temperature"`
	Tran        string       `json:"tran"`
	MinIO       uint64       `json:"min-io"`
	UsedPercent float64      `json:"used_percent"`
	Serial      string       `json:"serial"`
	Children    []LSBLKModel `json:"children"`
	SubSystems  string       `json:"subsystems"`
	Label       string       `json:"label"`
	// 详情特有
	StartSector uint64 `json:"start_sector,omitempty"`
	Rota        bool   `json:"rota"` // true(hhd) false(ssd)
	DiskType    string `json:"disk_type"`
	EndSector   uint64 `json:"end_sector,omitempty"`
}

func (*LSBLKModel) GetMountPoint

func (m *LSBLKModel) GetMountPoint(name string) string
type Link struct {
	URL        string         `json:"url"`
	Header     http.Header    `json:"header"` // needed header
	Data       io.ReadCloser  // return file reader directly
	Status     int            // status maybe 200 or 206, etc
	FilePath   *string        // local file, return the filepath
	Expiration *time.Duration // url expiration time
	Method     string         `json:"method"` // http method
}

type LinkArgs added in v0.4.3

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

type ListArgs added in v0.4.3

type ListArgs struct {
	ReqPath string
}

type Obj added in v0.4.3

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

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

func UnwrapObjs added in v0.4.3

func UnwrapObjs(obj Obj) Obj

func WrapObjName added in v0.4.3

func WrapObjName(objs Obj) Obj

Wrap

type ObjMerge added in v0.4.3

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

func NewObjMerge added in v0.4.3

func NewObjMerge() *ObjMerge

Merge

func (*ObjMerge) InitHideReg added in v0.4.3

func (om *ObjMerge) InitHideReg(hides string)

func (*ObjMerge) Merge added in v0.4.3

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

func (*ObjMerge) Reset added in v0.4.3

func (om *ObjMerge) Reset()

type ObjThumb added in v0.4.3

type ObjThumb struct {
	Object
	Thumbnail
}

type ObjThumbURL added in v0.4.3

type ObjThumbURL struct {
	Object
	Thumbnail
	Url
}

type ObjWrapName added in v0.4.3

type ObjWrapName struct {
	Name string
	Obj
}

func (*ObjWrapName) GetName added in v0.4.3

func (o *ObjWrapName) GetName() string

func (*ObjWrapName) Unwrap added in v0.4.3

func (o *ObjWrapName) Unwrap() Obj

type Object added in v0.4.3

type Object struct {
	ID       string
	Path     string
	Name     string
	Size     int64
	Modified time.Time
	IsFolder bool
}

func (*Object) GetID added in v0.4.3

func (o *Object) GetID() string

func (*Object) GetName added in v0.4.3

func (o *Object) GetName() string

func (*Object) GetPath added in v0.4.3

func (o *Object) GetPath() string

func (*Object) GetSize added in v0.4.3

func (o *Object) GetSize() int64

func (*Object) IsDir added in v0.4.3

func (o *Object) IsDir() bool

func (*Object) ModTime added in v0.4.3

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

func (*Object) SetPath added in v0.4.3

func (o *Object) SetPath(id string)

type ObjectURL added in v0.4.3

type ObjectURL struct {
	Object
	Url
}

type OtherArgs added in v0.4.3

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

type Proxy added in v0.4.3

type Proxy struct {
	WebProxy     bool   `json:"web_proxy"`
	WebdavPolicy string `json:"webdav_policy"`
	DownProxyUrl string `json:"down_proxy_url"`
}

func (Proxy) Webdav302 added in v0.4.3

func (p Proxy) Webdav302() bool

func (Proxy) WebdavNative added in v0.4.3

func (p Proxy) WebdavNative() bool

func (Proxy) WebdavProxy added in v0.4.3

func (p Proxy) WebdavProxy() bool

type ServerModel

type ServerModel struct {
	USBAutoMount   string
	EnableMergerFS string
}

服务配置

type SetPath added in v0.4.3

type SetPath interface {
	SetPath(path string)
}

type SettingItem added in v0.4.3

type SettingItem struct {
	Key     string `json:"key" gorm:"primaryKey" binding:"required"` // unique key
	Value   string `json:"value"`                                    // 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.
}

func (SettingItem) IsDeprecated added in v0.4.3

func (s SettingItem) IsDeprecated() bool

type SmartctlA

type SmartctlA struct {
	Smartctl struct {
		Version      []int    `json:"version"`
		SvnRevision  string   `json:"svn_revision"`
		PlatformInfo string   `json:"platform_info"`
		BuildInfo    string   `json:"build_info"`
		Argv         []string `json:"argv"`
		ExitStatus   int      `json:"exit_status"`
		Messages     []struct {
			String   string `json:"string"`
			Severity string `json:"severity"`
		} `json:"messages"`
	} `json:"smartctl"`
	Device struct {
		Name     string `json:"name"`
		InfoName string `json:"info_name"`
		Type     string `json:"type"`
		Protocol string `json:"protocol"`
	} `json:"device"`
	ModelName       string `json:"model_name"`
	SerialNumber    string `json:"serial_number"`
	FirmwareVersion string `json:"firmware_version"`
	UserCapacity    struct {
		Blocks int   `json:"blocks"`
		Bytes  int64 `json:"bytes"`
	} `json:"user_capacity"`
	SmartStatus struct {
		Passed bool `json:"passed"`
	} `json:"smart_status"`
	AtaSmartData struct {
		OfflineDataCollection struct {
			Status struct {
				Value  int    `json:"value"`
				String string `json:"string"`
			} `json:"status"`
			CompletionSeconds int `json:"completion_seconds"`
		} `json:"offline_data_collection"`
		SelfTest struct {
			Status struct {
				Value  int    `json:"value"`
				String string `json:"string"`
				Passed bool   `json:"passed"`
			} `json:"status"`
			PollingMinutes struct {
				Short      int `json:"short"`
				Extended   int `json:"extended"`
				Conveyance int `json:"conveyance"`
			} `json:"polling_minutes"`
		} `json:"self_test"`
		Capabilities struct {
			Values                        []int `json:"values"`
			ExecOfflineImmediateSupported bool  `json:"exec_offline_immediate_supported"`
			OfflineIsAbortedUponNewCmd    bool  `json:"offline_is_aborted_upon_new_cmd"`
			OfflineSurfaceScanSupported   bool  `json:"offline_surface_scan_supported"`
			SelfTestsSupported            bool  `json:"self_tests_supported"`
			ConveyanceSelfTestSupported   bool  `json:"conveyance_self_test_supported"`
			SelectiveSelfTestSupported    bool  `json:"selective_self_test_supported"`
			AttributeAutosaveEnabled      bool  `json:"attribute_autosave_enabled"`
			ErrorLoggingSupported         bool  `json:"error_logging_supported"`
			GpLoggingSupported            bool  `json:"gp_logging_supported"`
		} `json:"capabilities"`
	} `json:"ata_smart_data"`
	PowerOnTime struct {
		Hours int `json:"hours"`
	} `json:"power_on_time"`
	PowerCycleCount int `json:"power_cycle_count"`
	Temperature     struct {
		Current int `json:"current"`
	} `json:"temperature"`
}

type Sort added in v0.4.3

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

type Storage

type Storage struct {
	UUID        string `json:"uuid"`
	MountPoint  string `json:"mount_point"`
	Size        string `json:"size"`
	Avail       string `json:"avail"`
	Used        string `json:"used"`
	Type        string `json:"type"`
	Path        string `json:"path"`
	DriveName   string `json:"drive_name"`
	Label       string `json:"label"`
	PersistedIn string `json:"persisted_in"` // none, fstab, casaos
}

type StorageA added in v0.4.3

type StorageA 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
	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
	Sort
	Proxy
}

func (*StorageA) GetStorage added in v0.4.3

func (s *StorageA) GetStorage() *StorageA

func (*StorageA) SetStatus added in v0.4.3

func (s *StorageA) SetStatus(status string)

func (*StorageA) SetStorage added in v0.4.3

func (s *StorageA) SetStorage(storage StorageA)

type Storages

type Storages struct {
	DiskName string    `json:"disk_name"`
	Size     uint64    `json:"size"`
	Path     string    `json:"path"`
	Children []Storage `json:"children"`
	Type     string    `json:"type"`
}

type Thumb added in v0.4.3

type Thumb interface {
	Thumb() string
}

type Thumbnail added in v0.4.3

type Thumbnail struct {
	Thumbnail string
}

func (Thumbnail) Thumb added in v0.4.3

func (t Thumbnail) Thumb() string

type URL added in v0.4.3

type URL interface {
	URL() string
}

type USBChildren

type USBChildren struct {
	Name       string `json:"name"`
	Size       uint64 `json:"size"`
	Avail      uint64 `json:"avail"`
	MountPoint string `json:"mount_point"`
}

type USBDriveStatus

type USBDriveStatus struct {
	Name     string        `json:"name"`
	Size     uint64        `json:"size"`
	Model    string        `json:"model"`
	Avail    uint64        `json:"avail"`
	Children []USBChildren `json:"children"`
}

type UnwrapObj added in v0.4.3

type UnwrapObj interface {
	Unwrap() Obj
}

type Url added in v0.4.3

type Url struct {
	Url string
}

func (Url) URL added in v0.4.3

func (w Url) URL() string

Jump to

Keyboard shortcuts

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