MCPcopy
hub / github.com/etcd-io/bbolt / surgeryClearPageFunc

Function surgeryClearPageFunc

cmd/bbolt/command/command_surgery.go:188–209  ·  view source on GitHub ↗
(srcDBPath string, cfg surgeryClearPageOptions)

Source from the content-addressed store, hash-verified

186}
187
188func surgeryClearPageFunc(srcDBPath string, cfg surgeryClearPageOptions) error {
189 if _, err := checkSourceDBPath(srcDBPath); err != nil {
190 return err
191 }
192
193 if err := common.CopyFile(srcDBPath, cfg.outputDBFilePath); err != nil {
194 return fmt.Errorf("[clear-page] copy file failed: %w", err)
195 }
196
197 needAbandonFreelist, err := surgeon.ClearPage(cfg.outputDBFilePath, common.Pgid(cfg.pageId))
198 if err != nil {
199 return fmt.Errorf("clear-page command failed: %w", err)
200 }
201
202 if needAbandonFreelist {
203 fmt.Fprintf(os.Stdout, "WARNING: The clearing has abandoned some pages that are not yet referenced from free list.\n")
204 fmt.Fprintf(os.Stdout, "Please consider executing `./bbolt surgery freelist abandon ...`\n")
205 }
206
207 fmt.Fprintf(os.Stdout, "The page (%d) was cleared\n", cfg.pageId)
208 return nil
209}
210
211type surgeryClearPageElementsOptions struct {
212 surgeryBaseOptions

Callers 1

Calls 5

CopyFileFunction · 0.92
ClearPageFunction · 0.92
PgidTypeAlias · 0.92
checkSourceDBPathFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected