@@ -42,10 +42,10 @@ func newLocalFileStorage(logger *zap.Logger, config *Config) (extension.Extensio
42
42
}, nil
43
43
}
44
44
45
- // Start does nothing
45
+ // Start runs cleanup if configured
46
46
func (lfs * localFileStorage ) Start (context.Context , component.Host ) error {
47
47
if lfs .cfg .Compaction .CleanupOnStart {
48
- lfs .cleanup (lfs .cfg .Compaction .Directory )
48
+ return lfs .cleanup (lfs .cfg .Compaction .Directory )
49
49
}
50
50
return nil
51
51
}
@@ -142,11 +142,11 @@ func isSafe(character rune) bool {
142
142
}
143
143
144
144
// cleanup left compaction temporary files from previous killed process
145
- func (c * localFileStorage ) cleanup (compactionDirectory string ) error {
145
+ func (lfs * localFileStorage ) cleanup (compactionDirectory string ) error {
146
146
pattern := filepath .Join (compactionDirectory , fmt .Sprintf ("%s*" , TempDbPrefix ))
147
147
contents , err := filepath .Glob (pattern )
148
148
if err != nil {
149
- c .logger .Info ("cleanup error listing temporary files" ,
149
+ lfs .logger .Info ("cleanup error listing temporary files" ,
150
150
zap .Error (err ))
151
151
return err
152
152
}
@@ -155,14 +155,14 @@ func (c *localFileStorage) cleanup(compactionDirectory string) error {
155
155
for _ , item := range contents {
156
156
err = os .Remove (item )
157
157
if err == nil {
158
- c .logger .Debug ("cleanup" ,
158
+ lfs .logger .Debug ("cleanup" ,
159
159
zap .String ("deletedFile" , item ))
160
160
} else {
161
161
errs = append (errs , err )
162
162
}
163
163
}
164
164
if errs != nil {
165
- c .logger .Info ("cleanup errors" ,
165
+ lfs .logger .Info ("cleanup errors" ,
166
166
zap .Error (errors .Join (errs ... )))
167
167
}
168
168
return nil
0 commit comments