-
Notifications
You must be signed in to change notification settings - Fork 0
/
data-updater.go
77 lines (59 loc) · 1.52 KB
/
data-updater.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 main
import (
"github.com/stephendparker/ao2d-data/assets"
log "github.com/sirupsen/logrus"
"github.com/Gurpartap/logrus-stack"
"os"
"flag"
)
const (
StagingFolderName = "ao2d-staging"
)
var (
generateClasses = false
cleanupInstallationFile = true
)
func init() {
log.SetLevel(log.DebugLevel)
log.SetOutput(os.Stdout)
log.AddHook(logrus_stack.StandardHook())
log.SetFormatter(&log.TextFormatter{})
flag.BoolVar(&generateClasses, "G", generateClasses, "Generate class files")
flag.BoolVar(&cleanupInstallationFile, "C", cleanupInstallationFile, "Cleanup installation file after data unzip")
}
func main() {
stagingLocation := os.TempDir() + "\\" + StagingFolderName
version, downloadUrl, err := assets.GetLatestVersionDetails()
if err != nil {
log.Errorln(err)
return
}
versionDataLocation := stagingLocation + "\\" + version
err = assets.RetrieveAssetFiles(downloadUrl, versionDataLocation, cleanupInstallationFile)
if err != nil {
log.Errorln(err)
return
}
updatedChecksums, err := assets.VerifyXsdChecksums(versionDataLocation)
if err != nil {
log.Errorln(err)
return
}
if generateClasses {
err := assets.GenerateClassFiles(versionDataLocation)
if err != nil {
log.Error(err)
return
}
}
_, err = assets.LoadData(versionDataLocation)
if err != nil {
log.Error(err)
return
}
log.Debug("dataFileLocation: ", versionDataLocation)
for k, _ := range updatedChecksums {
log.Warn("Updated XSD checksum, consider updating go class: " + k)
}
log.Debug("Complete.")
}