-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
index_options.go
69 lines (58 loc) Β· 1.94 KB
/
index_options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package photoprism
import "github.com/photoprism/photoprism/internal/entity"
// IndexOptions represents file indexing options.
type IndexOptions struct {
UID string
Action string
Path string
Rescan bool
Convert bool
Stack bool
FacesOnly bool
SkipArchived bool
ByteLimit int64
ResolutionLimit int
}
// NewIndexOptions returns new index options instance.
func NewIndexOptions(path string, rescan, convert, stack, facesOnly, skipArchived bool) IndexOptions {
result := IndexOptions{
UID: entity.Admin.GetUID(),
Action: ActionIndex,
Path: path,
Rescan: rescan,
Convert: convert,
Stack: stack,
FacesOnly: facesOnly,
SkipArchived: skipArchived,
ByteLimit: Config().OriginalsByteLimit(),
ResolutionLimit: Config().ResolutionLimit(),
}
return result
}
// SkipUnchanged checks if unchanged media files should be skipped.
func (o *IndexOptions) SkipUnchanged() bool {
return !o.Rescan
}
// SetUser sets the user who performs the index operation.
func (o *IndexOptions) SetUser(user *entity.User) *IndexOptions {
if o != nil && user != nil {
o.UID = user.GetUID()
}
return o
}
// IndexOptionsAll returns new index options with all options set to true.
func IndexOptionsAll() IndexOptions {
return NewIndexOptions("/", true, true, true, false, true)
}
// IndexOptionsFacesOnly returns new index options for updating faces only.
func IndexOptionsFacesOnly() IndexOptions {
return NewIndexOptions("/", true, true, true, true, true)
}
// IndexOptionsSingle returns new index options for unstacked, single files.
func IndexOptionsSingle() IndexOptions {
return NewIndexOptions("/", true, true, false, false, false)
}
// IndexOptionsNone returns new index options with all options set to false.
func IndexOptionsNone() IndexOptions {
return NewIndexOptions("", false, false, false, false, false)
}