cli: improved 'content rewrite'
removed confusing '--prefixed' option
print timestamp of contents as they are rewritten
"github.com/pkg/errors"
+ "github.com/kopia/kopia/internal/units"
"github.com/kopia/kopia/repo"
"github.com/kopia/kopia/repo/content"
)
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()
@@ -62,7 +62,7 @@ func runContentRewriteCommand(ctx context.Context, rep *repo.Repository) error {
optDeleted = " (deleted)"
}
- printStderr("Rewriting content %v (%v bytes) from pack %v%v\n", c.ID, c.Length, c.PackBlobID, optDeleted)
+ printStderr("Rewriting content %v (%v bytes) from pack %v%v %v\n", c.ID, c.Length, c.PackBlobID, optDeleted, formatTimestamp(c.Timestamp()))
mu.Lock()
totalBytes += int64(c.Length)
mu.Unlock()
@@ -83,7 +83,7 @@ func runContentRewriteCommand(ctx context.Context, rep *repo.Repository) error {
wg.Wait()
- printStderr("Total bytes rewritten %v\n", totalBytes)
+ printStderr("Total bytes rewritten %v\n", units.BytesStringBase10(totalBytes))
if failedCount == 0 {
return nil
@@ -150,9 +150,7 @@ func(b content.Info) error {
func findContentInShortPacks(ctx context.Context, rep *repo.Repository, ch chan contentInfoOrError, threshold int64) {
if err := rep.Content.IterateContentInShortPacks(ctx, threshold, func(ci content.Info) error {
- if ci.ID.HasPrefix() == *contentRewritePrefixed {
ch <- contentInfoOrError{Info: ci}
- }
return nil
}); err != nil {
ch <- contentInfoOrError{err: err}
