Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alist-org
GitHub Repository: alist-org/alist
Path: blob/main/internal/model/object.go
2309 views
1
package model
2
3
import (
4
"time"
5
6
"github.com/alist-org/alist/v3/pkg/utils"
7
)
8
9
type ObjWrapName struct {
10
Name string
11
Obj
12
}
13
14
type ObjWrapStorageClass struct {
15
storageClass string
16
Obj
17
}
18
19
func (o *ObjWrapName) Unwrap() Obj {
20
return o.Obj
21
}
22
23
func (o *ObjWrapName) GetName() string {
24
return o.Name
25
}
26
27
func (o *ObjWrapStorageClass) Unwrap() Obj {
28
return o.Obj
29
}
30
31
func (o *ObjWrapStorageClass) StorageClass() string {
32
return o.storageClass
33
}
34
35
func (o *ObjWrapStorageClass) SetPath(path string) {
36
if setter, ok := o.Obj.(SetPath); ok {
37
setter.SetPath(path)
38
}
39
}
40
41
type Object struct {
42
ID string
43
Path string
44
Name string
45
Size int64
46
Modified time.Time
47
Ctime time.Time // file create time
48
IsFolder bool
49
HashInfo utils.HashInfo
50
}
51
52
func (o *Object) GetName() string {
53
return o.Name
54
}
55
56
func (o *Object) GetSize() int64 {
57
return o.Size
58
}
59
60
func (o *Object) ModTime() time.Time {
61
return o.Modified
62
}
63
func (o *Object) CreateTime() time.Time {
64
if o.Ctime.IsZero() {
65
return o.ModTime()
66
}
67
return o.Ctime
68
}
69
70
func (o *Object) IsDir() bool {
71
return o.IsFolder
72
}
73
74
func (o *Object) GetID() string {
75
return o.ID
76
}
77
78
func (o *Object) GetPath() string {
79
return o.Path
80
}
81
82
func (o *Object) SetPath(path string) {
83
o.Path = path
84
}
85
86
func (o *Object) GetHash() utils.HashInfo {
87
return o.HashInfo
88
}
89
90
type Thumbnail struct {
91
Thumbnail string
92
}
93
94
type Url struct {
95
Url string
96
}
97
98
func (w Url) URL() string {
99
return w.Url
100
}
101
102
func (t Thumbnail) Thumb() string {
103
return t.Thumbnail
104
}
105
106
type ObjThumb struct {
107
Object
108
Thumbnail
109
}
110
111
type ObjectURL struct {
112
Object
113
Url
114
}
115
116
type ObjThumbURL struct {
117
Object
118
Thumbnail
119
Url
120
}
121
122