-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
import_options.go
77 lines (67 loc) Β· 2.2 KB
/
import_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
70
71
72
73
74
75
76
77
package photoprism
import "github.com/photoprism/photoprism/internal/entity"
// ImportOptions represents file import options.
type ImportOptions struct {
UID string
Action string
Albums []string
Path string
Move bool
NonBlocking bool
DestFolder string
RemoveDotFiles bool
RemoveExistingFiles bool
RemoveEmptyDirectories bool
}
// SetUser sets the user who performs the import operation.
func (o *ImportOptions) SetUser(user *entity.User) *ImportOptions {
if o != nil && user != nil {
o.UID = user.GetUID()
}
return o
}
// ImportOptionsCopy returns import options for copying files to originals (read-only).
func ImportOptionsCopy(importPath, destFolder string) ImportOptions {
result := ImportOptions{
UID: entity.Admin.GetUID(),
Action: ActionImport,
Path: importPath,
Move: false,
NonBlocking: false,
DestFolder: destFolder,
RemoveDotFiles: false,
RemoveExistingFiles: false,
RemoveEmptyDirectories: false,
}
return result
}
// ImportOptionsMove returns import options for moving files to originals (modifies import directory).
func ImportOptionsMove(importPath, destFolder string) ImportOptions {
result := ImportOptions{
UID: entity.Admin.GetUID(),
Action: ActionImport,
Path: importPath,
Move: true,
NonBlocking: false,
DestFolder: destFolder,
RemoveDotFiles: true,
RemoveExistingFiles: true,
RemoveEmptyDirectories: true,
}
return result
}
// ImportOptionsUpload returns options for importing user uploads.
func ImportOptionsUpload(uploadPath, destFolder string) ImportOptions {
result := ImportOptions{
UID: entity.Admin.GetUID(),
Action: ActionUpload,
Path: uploadPath,
Move: true,
NonBlocking: true,
DestFolder: destFolder,
RemoveDotFiles: true,
RemoveExistingFiles: true,
RemoveEmptyDirectories: true,
}
return result
}