model

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

@Author: LinkLeong link@icewhale.com

*@Date: 2022-07-13 10:43:45
*@LastEditors: LinkLeong
*@LastEditTime: 2022-08-03 14:45:35
*@FilePath: /DappsterOS/model/disk.go
*@Description:
*@Website: https://www.dappsteros.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

func ExtractFolder(objs []Obj, extractFolder string)

func GetThumb

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

func GetUrl

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

func SortFiles

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

func WrapObjsName

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

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

type DiskChildren

type DiskChildren struct {
	Name      string `json:"name"`
	Size      uint64 `json:"size"`
	Format    string `json:"format"`
	Supported bool   `json:"supported"`
}

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"`
	Children       []DiskChildren `json:"children"`
	Supported      bool           `json:"supported"`
}

type FileStream

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

func (*FileStream) GetMimetype

func (f *FileStream) GetMimetype() string

func (*FileStream) GetOld

func (f *FileStream) GetOld() Obj

func (*FileStream) GetReadCloser

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

func (*FileStream) NeedStore

func (f *FileStream) NeedStore() bool

func (*FileStream) SetReadCloser

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

type FileStreamer

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

type FsOtherArgs

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

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

type ListArgs

type ListArgs struct {
	ReqPath string
}

type Obj

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

func UnwrapObjs(obj Obj) Obj

func WrapObjName

func WrapObjName(objs Obj) Obj

Wrap

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 ObjThumb

type ObjThumb struct {
	Object
	Thumbnail
}

type ObjThumbURL

type ObjThumbURL struct {
	Object
	Thumbnail
	Url
}

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
	IsFolder bool
}

func (*Object) GetID

func (o *Object) GetID() string

func (*Object) GetName

func (o *Object) GetName() string

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(id string)

type ObjectURL

type ObjectURL struct {
	Object
	Url
}

type OtherArgs

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

type Proxy

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

func (Proxy) Webdav302

func (p Proxy) Webdav302() bool

func (Proxy) WebdavNative

func (p Proxy) WebdavNative() bool

func (Proxy) WebdavProxy

func (p Proxy) WebdavProxy() bool

type ServerModel

type ServerModel struct {
	USBAutoMount   string
	EnableMergerFS string
}

服务配置

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
	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

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

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, dappsteros
}

type StorageA

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

func (s *StorageA) GetStorage() *StorageA

func (*StorageA) SetStatus

func (s *StorageA) SetStatus(status string)

func (*StorageA) SetStorage

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

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 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

type UnwrapObj interface {
	Unwrap() Obj
}

type Url

type Url struct {
	Url string
}

func (Url) URL

func (w Url) URL() string

Jump to

Keyboard shortcuts

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