Skip to content

Commit

Permalink
refactoring: renamed repo/block to repo/content
Browse files Browse the repository at this point in the history
Also introduced strongly typed content.ID and manifest.ID (instead of string)

This aligns identifiers across all layers of repository:

blob.ID
content.ID
object.ID
manifest.ID
  • Loading branch information
jkowalski committed Jun 2, 2019
1 parent 916da07 commit 54edb97
Show file tree
Hide file tree
Showing 100 changed files with 2,692 additions and 2,658 deletions.
14 changes: 7 additions & 7 deletions cli/app.go
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/kopia/kopia/internal/serverapi"
"github.com/kopia/kopia/repo"
"github.com/kopia/kopia/repo/blob"
"github.com/kopia/kopia/repo/block"
"github.com/kopia/kopia/repo/content"

kingpin "gopkg.in/alecthomas/kingpin.v2"
)
Expand All @@ -31,9 +31,9 @@ var (
policyCommands = app.Command("policy", "Commands to manipulate snapshotting policies.").Alias("policies")
serverCommands = app.Command("server", "Commands to control HTTP API server.")
manifestCommands = app.Command("manifest", "Low-level commands to manipulate manifest items.").Hidden()
blockCommands = app.Command("block", "Commands to manipulate virtual blocks in repository.").Alias("blk").Hidden()
contentCommands = app.Command("content", "Commands to manipulate content in repository.").Alias("contents").Hidden()
blobCommands = app.Command("blob", "Commands to manipulate BLOBs.").Hidden()
blockIndexCommands = app.Command("blockindex", "Commands to manipulate block index.").Hidden()
indexCommands = app.Command("index", "Commands to manipulate content index.").Hidden()
benchmarkCommands = app.Command("benchmark", "Commands to test performance of algorithms.").Hidden()
)

Expand All @@ -58,8 +58,8 @@ func serverAction(act func(ctx context.Context, cli *serverapi.Client) error) fu
func repositoryAction(act func(ctx context.Context, rep *repo.Repository) error) func(ctx *kingpin.ParseContext) error {
return func(kpc *kingpin.ParseContext) error {
ctx := context.Background()
ctx = block.UsingBlockCache(ctx, *enableCaching)
ctx = block.UsingListCache(ctx, *enableListCaching)
ctx = content.UsingContentCache(ctx, *enableCaching)
ctx = content.UsingListCache(ctx, *enableListCaching)
ctx = blob.WithUploadProgressCallback(ctx, func(desc string, progress, total int64) {
cliProgress.Report("upload '"+desc+"'", progress, total)
})
Expand All @@ -70,13 +70,13 @@ func repositoryAction(act func(ctx context.Context, rep *repo.Repository) error)

storageType := rep.Blobs.ConnectionInfo().Type

reportStartupTime(storageType, rep.Blocks.Format.Version, repositoryOpenTime)
reportStartupTime(storageType, rep.Content.Format.Version, repositoryOpenTime)

t1 := time.Now()
err := act(ctx, rep)
commandDuration := time.Since(t1)

reportSubcommandFinished(kpc.SelectedCommand.FullCommand(), err == nil, storageType, rep.Blocks.Format.Version, commandDuration)
reportSubcommandFinished(kpc.SelectedCommand.FullCommand(), err == nil, storageType, rep.Content.Format.Version, commandDuration)
if cerr := rep.Close(ctx); cerr != nil {
return errors.Wrap(cerr, "unable to close repository")
}
Expand Down
12 changes: 6 additions & 6 deletions cli/command_benchmark_crypto.go
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/kopia/kopia/internal/units"
"github.com/kopia/kopia/repo/block"
"github.com/kopia/kopia/repo/content"

kingpin "gopkg.in/alecthomas/kingpin.v2"
)
Expand All @@ -27,14 +27,14 @@ func runBenchmarkCryptoAction(ctx *kingpin.ParseContext) error {
var results []benchResult

data := make([]byte, *benchmarkCryptoBlockSize)
for _, ha := range block.SupportedHashAlgorithms() {
for _, ea := range block.SupportedEncryptionAlgorithms() {
for _, ha := range content.SupportedHashAlgorithms() {
for _, ea := range content.SupportedEncryptionAlgorithms() {
isEncrypted := ea != "NONE"
if *benchmarkCryptoEncryption != isEncrypted {
continue
}

h, e, err := block.CreateHashAndEncryptor(block.FormattingOptions{
h, e, err := content.CreateHashAndEncryptor(content.FormattingOptions{
Encryption: ea,
Hash: ha,
MasterKey: make([]byte, 32),
Expand All @@ -48,8 +48,8 @@ func runBenchmarkCryptoAction(ctx *kingpin.ParseContext) error {
t0 := time.Now()
hashCount := *benchmarkCryptoRepeat
for i := 0; i < hashCount; i++ {
blockID := h(data)
if _, encerr := e.Encrypt(data, blockID); encerr != nil {
contentID := h(data)
if _, encerr := e.Encrypt(data, contentID); encerr != nil {
log.Warningf("encryption failed: %v", encerr)
break
}
Expand Down
4 changes: 2 additions & 2 deletions cli/command_blob_delete.go
Expand Up @@ -14,7 +14,7 @@ var (
blobDeleteBlobIDs = blobDeleteCommand.Arg("blobIDs", "Blob IDs").Required().Strings()
)

func runDeleteStorageBlocks(ctx context.Context, rep *repo.Repository) error {
func runDeleteBlobs(ctx context.Context, rep *repo.Repository) error {
for _, b := range *blobDeleteBlobIDs {
err := rep.Blobs.DeleteBlob(ctx, blob.ID(b))
if err != nil {
Expand All @@ -26,5 +26,5 @@ func runDeleteStorageBlocks(ctx context.Context, rep *repo.Repository) error {
}

func init() {
blobDeleteCommand.Action(repositoryAction(runDeleteStorageBlocks))
blobDeleteCommand.Action(repositoryAction(runDeleteBlobs))
}
50 changes: 0 additions & 50 deletions cli/command_block_gc.go

This file was deleted.

29 changes: 0 additions & 29 deletions cli/command_block_index_optimize.go

This file was deleted.

101 changes: 0 additions & 101 deletions cli/command_block_list.go

This file was deleted.

0 comments on commit 54edb97

Please sign in to comment.