2022-08-23 14:05:32 +00:00
|
|
|
package meta
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
common "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal"
|
|
|
|
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
2022-08-23 14:05:32 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var listGarbageCMD = &cobra.Command{
|
|
|
|
Use: "list-garbage",
|
|
|
|
Short: "Garbage listing",
|
|
|
|
Long: `List all the objects that have received GC Mark.`,
|
|
|
|
Run: listGarbageFunc,
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
common.AddComponentPathFlag(listGarbageCMD, &vPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
func listGarbageFunc(cmd *cobra.Command, _ []string) {
|
2022-08-24 12:09:52 +00:00
|
|
|
db := openMeta(cmd)
|
2024-10-21 13:27:28 +00:00
|
|
|
defer db.Close(cmd.Context())
|
2022-08-23 14:05:32 +00:00
|
|
|
|
|
|
|
var garbPrm meta.GarbageIterationPrm
|
|
|
|
garbPrm.SetHandler(
|
|
|
|
func(garbageObject meta.GarbageObject) error {
|
|
|
|
cmd.Println(garbageObject.Address().EncodeToString())
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
2023-06-06 09:27:19 +00:00
|
|
|
err := db.IterateOverGarbage(cmd.Context(), garbPrm)
|
2022-08-23 14:05:32 +00:00
|
|
|
common.ExitOnErr(cmd, common.Errf("could not iterate over garbage bucket: %w", err))
|
|
|
|
}
|