-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathutils.go
47 lines (42 loc) · 1.26 KB
/
utils.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
package msi
import (
"github.com/itchio/butler/cmd/msi"
"github.com/itchio/butler/installer"
"github.com/itchio/wharf/state"
"github.com/mitchellh/mapstructure"
)
func shouldTryElevated(consumer *state.Consumer, res *installer.RunSelfResult) bool {
for _, val := range res.Results {
switch val["type"] {
case "windowsInstallerError":
var me msi.MSIWindowsInstallerError
dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
Result: &me,
})
if err != nil {
consumer.Errorf("Could not decode msi windows installer error: %s", err.Error())
continue
}
dec.Decode(val["value"])
if err != nil {
consumer.Errorf("Could not decode msi windows installer error: %s", err.Error())
continue
}
switch me.Code {
case 1925:
consumer.Infof("MSI complained about elevation, will retry elevated. Original error: ")
consumer.Infof(me.Text)
return true
case 1721:
consumer.Infof("MSI complained about a program it needs to run, will retry elevated. Original error: ")
consumer.Infof(me.Text)
return true
case 1406:
consumer.Infof("MSI complained about a registry key it needs to write, will retry elevated. Original error: ")
consumer.Infof(me.Text)
return true
}
}
}
return false
}