-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
69 lines (65 loc) · 2.05 KB
/
main.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 main
import (
"flag"
"runtime"
"strings"
"time"
)
var (
concurrency chan struct{}
inFolder = ""
outFolder = ""
minFolderDate time.Time
exclusions = map[string]struct{}{}
alwaysProcessRotatedImages = false
plausibility = false
)
func main() {
threads, path := shellArguments()
stats.Path = path
concurrency = make(chan struct{}, threads)
p := strings.Split(path, "/")
name := p[len(p)-1]
if path == "" {
name = "Fotos"
}
feedLines()
printStats(nil)
running := true
go func() {
for running {
printStats(nil)
time.Sleep(5 * time.Second)
}
}()
_, _, err := Walk(name, path)
if err != nil {
printStats(err)
}
running = false
}
func shellArguments() (int, string) {
threadsPtr := flag.Int("threads", runtime.NumCPU(), "the number of goroutines that are allowed to run concurrently")
inFolderPtr := flag.String("in", "./volume/Fotos", "the root folder from which files are read")
outFolderPtr := flag.String("out", "./volume/Thumbs", "the root folder where thumbnails are stored")
pathPtr := flag.String("path", "", "the relative path from which photos are updated, no leading or trailing slashes")
maxAgePtr := flag.Duration("maxage", 0, "the maximum age after which folders are scanned again, e.g. 48h")
excludePtr := flag.String("exclude", "", "excluded folders, comma separated, e.g. snapshot")
alwaysProcessRotatedImagesPtr := flag.Bool("always-process-rotated-images", false, "Do not skip unmodified rotated CR2 files")
plausibilityPtr := flag.Bool("plausibility", false, "Assume correct rotation when image is upright and requires 90 degree rotation")
flag.Parse()
threads := *threadsPtr
inFolder = *inFolderPtr
outFolder = *outFolderPtr
path := *pathPtr
maxAge := *maxAgePtr
alwaysProcessRotatedImages = *alwaysProcessRotatedImagesPtr
plausibility = *plausibilityPtr
if maxAge > 0 {
minFolderDate = time.Now().Add(-maxAge)
}
for _, v := range strings.Split(*excludePtr, ",") {
exclusions[v] = struct{}{}
}
return threads, path
}