-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathcommit.go
79 lines (65 loc) · 1.74 KB
/
commit.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
78
79
package operate
import (
"github.com/itchio/butler/butlerd"
"github.com/itchio/butler/butlerd/messages"
"github.com/itchio/butler/installer"
"github.com/itchio/butler/installer/bfs"
"github.com/itchio/butler/manager"
itchio "github.com/itchio/go-itchio"
"github.com/itchio/ox"
"github.com/pkg/errors"
)
type CommitInstallParams struct {
InstallerName string
InstallFolder string
Game *itchio.Game
Upload *itchio.Upload
Build *itchio.Build
InstallResult *installer.InstallResult
}
func commitInstall(oc *OperationContext, params *CommitInstallParams) error {
consumer := oc.Consumer()
res := params.InstallResult
err := messages.TaskSucceeded.Notify(oc.rc, butlerd.TaskSucceededNotification{
Type: butlerd.TaskTypeInstall,
InstallResult: &butlerd.InstallResult{
Game: params.Game,
Upload: params.Upload,
Build: params.Build,
},
})
if err != nil {
return errors.WithStack(err)
}
consumer.Opf("Writing receipt...")
receipt := &bfs.Receipt{
InstallerName: params.InstallerName,
Game: params.Game,
Upload: params.Upload,
Build: params.Build,
Files: res.Files,
// optionals:
MSIProductCode: res.MSIProductCode,
}
err = receipt.WriteReceipt(params.InstallFolder)
if err != nil {
return errors.WithStack(err)
}
cave := oc.cave
if cave != nil {
// TODO: pass runtime in params?
verdict, err := manager.Configure(consumer, params.InstallFolder, ox.CurrentRuntime())
if err != nil {
return errors.WithStack(err)
}
consumer.Opf("Saving cave...")
cave.SetVerdict(verdict)
cave.InstalledSize = verdict.TotalSize
cave.Game = params.Game
cave.Upload = params.Upload
cave.Build = params.Build
cave.UpdateInstallTime()
oc.rc.WithConn(cave.SaveWithAssocs)
}
return nil
}