@@ -53,8 +53,7 @@ func NewPlan(smgr statemanager.Manager, cfg *configloader.Config) *Plan {
53
53
smgr .SetStates (states )
54
54
log .Println ("succeeded to initialize States" )
55
55
} else {
56
- log .Printf ("failed to initialize States. Error: (%s)" , err )
57
- log .Println ("try to initialize the States." )
56
+ log .Printf ("failed to initialize States. Error: (%s). try to initialize the States" , err )
58
57
}
59
58
60
59
plan := & Plan {
@@ -73,7 +72,10 @@ func NewPlan(smgr statemanager.Manager, cfg *configloader.Config) *Plan {
73
72
// All errors will be return.
74
73
func (p * Plan ) Execute () []error {
75
74
errors := make ([]error , 0 )
76
- for _ , c := range p .Changes {
75
+ log .Printf ("changes count: %d" , len (p .Changes ))
76
+ for i , c := range p .Changes {
77
+ log .Printf ("procprocessing progress: %d/%d" , i + 1 , len (p .Changes ))
78
+ log .Printf ("processing: %s -> %s" , c .Tool .Name , c .ActionName )
77
79
// We will consider how to execute Action concurrently later.
78
80
// It involves dependency management.
79
81
succeeded , err := c .Action (c .Tool )
@@ -97,6 +99,11 @@ func (p *Plan) Execute() []error {
97
99
98
100
// handleResult is used to Write the latest States to Backend.
99
101
func (p * Plan ) handleResult (change * Change ) error {
102
+ if change .ActionName == statemanager .ActionUninstall {
103
+ p .smgr .DeleteState (change .Tool .Name )
104
+ return p .smgr .Write (p .smgr .GetStates ().Format ())
105
+ }
106
+
100
107
var state = statemanager .NewState (
101
108
change .Tool .Name ,
102
109
change .Tool .Version ,
@@ -111,9 +118,9 @@ func (p *Plan) handleResult(change *Change) error {
111
118
112
119
if change .Result .Error != nil {
113
120
state .Status = statemanager .StatusFailed
114
- log .Printf ("=== plugin %s installation failed ===" , change .Tool .Name )
121
+ log .Printf ("=== plugin %s process failed ===" , change .Tool .Name )
115
122
} else {
116
- log .Printf ("=== plugin %s installation done ===" , change .Tool .Name )
123
+ log .Printf ("=== plugin %s process done ===" , change .Tool .Name )
117
124
}
118
125
119
126
p .smgr .AddState (state )
0 commit comments