From 829faf8e1a9b3c17413fa16fd2bda76940d648e7 Mon Sep 17 00:00:00 2001 From: Jarek Kowalski Date: Thu, 18 Jul 2019 18:43:54 -1000 Subject: [PATCH] added 'rewrite --prefixed' flag to only rewrite prefixed content IDs (by default only rewrites non-prefixed IDs) --- cli/command_content_rewrite.go | 5 ++++- cli/command_repository_repair.go | 2 +- cli/command_snapshot_migrate.go | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cli/command_content_rewrite.go b/cli/command_content_rewrite.go index 4131e4d47..5fa1bb51b 100644 --- a/cli/command_content_rewrite.go +++ b/cli/command_content_rewrite.go @@ -16,6 +16,7 @@ var ( contentRewriteCommand = contentCommands.Command("rewrite", "Rewrite content using most recent format") contentRewriteIDs = contentRewriteCommand.Arg("contentID", "Identifiers of contents to rewrite").Strings() + contentRewritePrefixed = contentRewriteCommand.Flag("prefixed", "Rewrite contents with a non-empty prefix").Bool() contentRewriteParallelism = contentRewriteCommand.Flag("parallelism", "Number of parallel workers").Default("16").Int() contentRewriteShortPacks = contentRewriteCommand.Flag("short", "Rewrite contents from short packs").Bool() @@ -160,7 +161,9 @@ func findContentInShortPacks(rep *repo.Repository, ch chan contentInfoOrError, t } else { for _, b := range infos { if shortPackBlocks[b.PackBlobID] && strings.HasPrefix(string(b.PackBlobID), *contentRewritePackPrefix) { - ch <- contentInfoOrError{Info: b} + if b.ID.HasPrefix() == *contentRewritePrefixed { + ch <- contentInfoOrError{Info: b} + } } } } diff --git a/cli/command_repository_repair.go b/cli/command_repository_repair.go index bcb1d2618..d3f9ec680 100644 --- a/cli/command_repository_repair.go +++ b/cli/command_repository_repair.go @@ -11,7 +11,7 @@ ) var ( - repairCommand = repositoryCommands.Command("repair", "Repairs respository.") + repairCommand = repositoryCommands.Command("repair", "Repairs repository.") repairCommandRecoverFormatBlob = repairCommand.Flag("recover-format", "Recover format blob from a copy").Default("auto").Enum("auto", "yes", "no") repairCommandRecoverFormatBlobPrefixes = repairCommand.Flag("recover-format-block-prefixes", "Prefixes of file names").Strings() diff --git a/cli/command_snapshot_migrate.go b/cli/command_snapshot_migrate.go index 7f4cac3d8..bf3b0c69e 100644 --- a/cli/command_snapshot_migrate.go +++ b/cli/command_snapshot_migrate.go @@ -55,7 +55,7 @@ func runMigrateCommand(ctx context.Context, destRepo *repo.Repository) error { if !canceled { canceled = true for s, u := range activeUploaders { - log.Warningf("cancelling active uploader for %v", s) + log.Warningf("canceling active uploader for %v", s) u.Cancel() } }