From 6301fb19f74a191993430f27aede3c8af1050080 Mon Sep 17 00:00:00 2001 From: marston Date: Sun, 21 Apr 2024 11:49:37 -0400 Subject: [PATCH] prune combo flag --- jprov/jprovd/provider_commands.go | 15 ++++++++++++++- jprov/types/flags.go | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/jprov/jprovd/provider_commands.go b/jprov/jprovd/provider_commands.go index df296c8..a7b15f5 100644 --- a/jprov/jprovd/provider_commands.go +++ b/jprov/jprovd/provider_commands.go @@ -311,6 +311,11 @@ func MigrateCommand() *cobra.Command { Long: `Migrate old file system. This will glue all blocks together into one file per fids stored in your machine`, Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { + prune, err := cmd.Flags().GetBool(types.FlagPruneFirst) + if err != nil { + return err + } + buf := bufio.NewReader(cmd.InOrStdin()) yes, err := input.GetConfirmation("Are you sure you want to migrate from old file system?", buf, cmd.ErrOrStderr()) if err != nil { @@ -374,8 +379,15 @@ func MigrateCommand() *cobra.Command { return err } + if prune { + err := fs.PruneExpiredFiles() + if err != nil { + return err + } + } utils.Migrate(clientCtx, chunkSize) - return err + + return nil }, } AddTxFlagsToCmd(cmd) @@ -393,6 +405,7 @@ func MigrateCommand() *cobra.Command { cmd.Flags().String(types.FlagProviderName, "A Storage Provider", "The name to identify this provider in block explorers.") cmd.Flags().Int64(types.FlagSleep, types.DefaultSleep, "The time, in milliseconds, before adding another proof msg to the queue.") cmd.Flags().Bool(types.FlagDoReport, types.DefaultDoReport, "Should this provider report deals (uses gas).") + cmd.Flags().Bool(types.FlagPruneFirst, false, "Should the provider prune its state before migration?") return cmd } diff --git a/jprov/types/flags.go b/jprov/types/flags.go index 591f23b..7865281 100644 --- a/jprov/types/flags.go +++ b/jprov/types/flags.go @@ -14,6 +14,7 @@ const ( FlagProviderName = "moniker" FlagSleep = "sleep" FlagDoReport = "do-report" + FlagPruneFirst = "prune" ) const (