(srcDBPath string, cfg surgeryClearPageOptions)
| 186 | } |
| 187 | |
| 188 | func 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 | |
| 211 | type surgeryClearPageElementsOptions struct { |
| 212 | surgeryBaseOptions |
no test coverage detected