Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alist-org
GitHub Repository: alist-org/alist
Path: blob/main/internal/model/storage.go
1560 views
1
package model
2
3
import (
4
"time"
5
)
6
7
type Storage struct {
8
ID uint `json:"id" gorm:"primaryKey"` // unique key
9
MountPath string `json:"mount_path" gorm:"unique" binding:"required"` // must be standardized
10
Order int `json:"order"` // use to sort
11
Driver string `json:"driver"` // driver used
12
CacheExpiration int `json:"cache_expiration"` // cache expire time
13
Status string `json:"status"`
14
Addition string `json:"addition" gorm:"type:text"` // Additional information, defined in the corresponding driver
15
Remark string `json:"remark"`
16
Modified time.Time `json:"modified"`
17
Disabled bool `json:"disabled"` // if disabled
18
DisableIndex bool `json:"disable_index"`
19
EnableSign bool `json:"enable_sign"`
20
Sort
21
Proxy
22
}
23
24
type Sort struct {
25
OrderBy string `json:"order_by"`
26
OrderDirection string `json:"order_direction"`
27
ExtractFolder string `json:"extract_folder"`
28
}
29
30
type Proxy struct {
31
WebProxy bool `json:"web_proxy"`
32
WebdavPolicy string `json:"webdav_policy"`
33
ProxyRange bool `json:"proxy_range"`
34
DownProxyUrl string `json:"down_proxy_url"`
35
}
36
37
func (s *Storage) GetStorage() *Storage {
38
return s
39
}
40
41
func (s *Storage) SetStorage(storage Storage) {
42
*s = storage
43
}
44
45
func (s *Storage) SetStatus(status string) {
46
s.Status = status
47
}
48
49
func (p Proxy) Webdav302() bool {
50
return p.WebdavPolicy == "302_redirect"
51
}
52
53
func (p Proxy) WebdavProxy() bool {
54
return p.WebdavPolicy == "use_proxy_url"
55
}
56
57
func (p Proxy) WebdavNative() bool {
58
return !p.Webdav302() && !p.WebdavProxy()
59
}
60
61