mirror of
https://github.com/kopia/kopia.git
synced 2026-10-24 23:28:47 -04:00
refactored repository status
This commit is contained in:
1 parent
b6575a97ba
commit
0f6c569435
2 files changed
+13
-64
No files matched your search
@@ -17,8 +17,6 @@ func runStatusCommand(context *kingpin.ParseContext) error {
|
||||
rep := mustOpenRepository(nil)
|
||||
defer rep.Close()
|
||||
|
||||
s := rep.Status()
|
||||
|
||||
fmt.Printf("Config file: %v\n", rep.ConfigFile)
|
||||
fmt.Printf("Cache directory: %v\n", rep.CacheDirectory)
|
||||
fmt.Println()
|
||||
@@ -34,28 +32,28 @@ func runStatusCommand(context *kingpin.ParseContext) error {
|
||||
|
||||
var splitterExtraInfo string
|
||||
|
||||
switch s.Splitter {
|
||||
switch rep.Objects.Format.Splitter {
|
||||
case "DYNAMIC":
|
||||
splitterExtraInfo = fmt.Sprintf(
|
||||
" (min: %v; avg: %v; max: %v)",
|
||||
units.BytesStringBase2(int64(s.MinBlockSize)),
|
||||
units.BytesStringBase2(int64(s.AvgBlockSize)),
|
||||
units.BytesStringBase2(int64(s.MaxBlockSize)))
|
||||
units.BytesStringBase2(int64(rep.Objects.Format.MinBlockSize)),
|
||||
units.BytesStringBase2(int64(rep.Objects.Format.AvgBlockSize)),
|
||||
units.BytesStringBase2(int64(rep.Objects.Format.MaxBlockSize)))
|
||||
case "":
|
||||
case "FIXED":
|
||||
splitterExtraInfo = fmt.Sprintf(" %v", units.BytesStringBase2(int64(s.MaxBlockSize)))
|
||||
splitterExtraInfo = fmt.Sprintf(" %v", units.BytesStringBase2(int64(rep.Objects.Format.MaxBlockSize)))
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
fmt.Printf("Metadata manager: v%v\n", s.MetadataManagerVersion)
|
||||
fmt.Printf("Metadata Encryption: %v\n", s.MetadataEncryptionAlgorithm)
|
||||
fmt.Printf("Key Derivation: %v\n", s.KeyDerivationAlgorithm)
|
||||
fmt.Printf("Unique ID: %v\n", s.UniqueID)
|
||||
fmt.Printf("Metadata manager: v%v\n", rep.Metadata.Format.Version)
|
||||
fmt.Printf("Metadata Encryption: %v\n", rep.Metadata.Format.EncryptionAlgorithm)
|
||||
fmt.Printf("Key Derivation: %v\n", rep.Security.KeyDerivationAlgorithm)
|
||||
fmt.Printf("Unique ID: %x\n", rep.Security.UniqueID)
|
||||
fmt.Println()
|
||||
fmt.Printf("Object manager: v%v\n", s.ObjectManagerVersion)
|
||||
fmt.Printf("Block format: %v\n", s.BlockFormat)
|
||||
fmt.Printf("Splitter: %v%v\n", s.Splitter, splitterExtraInfo)
|
||||
fmt.Printf("Max packed len: %v\n", units.BytesStringBase2(int64(s.MaxPackedContentLength)))
|
||||
fmt.Printf("Object manager: v%v\n", rep.Objects.Format.Version)
|
||||
fmt.Printf("Block format: %v\n", rep.Objects.Format.BlockFormat)
|
||||
fmt.Printf("Splitter: %v%v\n", rep.Objects.Format.Splitter, splitterExtraInfo)
|
||||
fmt.Printf("Max packed len: %v\n", units.BytesStringBase2(int64(rep.Objects.Format.MaxPackedContentLength)))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/kopia/kopia/auth"
|
||||
"github.com/kopia/kopia/block"
|
||||
"github.com/kopia/kopia/metadata"
|
||||
@@ -24,52 +21,6 @@ type Repository struct {
|
||||
CacheDirectory string
|
||||
}
|
||||
|
||||
// StatusInfo stores a snapshot of repository-wide statistics plus some general information about repository configuration.
|
||||
type StatusInfo struct {
|
||||
block.Stats
|
||||
|
||||
MetadataManagerVersion string
|
||||
MetadataEncryptionAlgorithm string
|
||||
UniqueID string
|
||||
KeyDerivationAlgorithm string
|
||||
|
||||
ObjectManagerVersion string
|
||||
BlockFormat string
|
||||
Splitter string
|
||||
MinBlockSize int
|
||||
AvgBlockSize int
|
||||
MaxBlockSize int
|
||||
|
||||
MaxPackedContentLength int
|
||||
}
|
||||
|
||||
// Status returns a snapshot of repository-wide statistics plus some general information about repository configuration.
|
||||
func (r *Repository) Status() StatusInfo {
|
||||
s := StatusInfo{
|
||||
Stats: r.Blocks.Stats(),
|
||||
|
||||
MetadataManagerVersion: r.Metadata.Format.Version,
|
||||
UniqueID: hex.EncodeToString(r.Security.UniqueID),
|
||||
MetadataEncryptionAlgorithm: r.Metadata.Format.EncryptionAlgorithm,
|
||||
KeyDerivationAlgorithm: r.Security.KeyDerivationAlgorithm,
|
||||
|
||||
ObjectManagerVersion: fmt.Sprintf("%v", r.Objects.Format.Version),
|
||||
BlockFormat: r.Objects.Format.BlockFormat,
|
||||
Splitter: r.Objects.Format.Splitter,
|
||||
MinBlockSize: r.Objects.Format.MinBlockSize,
|
||||
AvgBlockSize: r.Objects.Format.AvgBlockSize,
|
||||
MaxBlockSize: r.Objects.Format.MaxBlockSize,
|
||||
|
||||
MaxPackedContentLength: r.Objects.Format.MaxPackedContentLength,
|
||||
}
|
||||
|
||||
if s.Splitter == "" {
|
||||
s.Splitter = "FIXED"
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
// Close closes the repository and releases all resources.
|
||||
func (r *Repository) Close() error {
|
||||
if err := r.Objects.Close(); err != nil {
|
||||
|
||||
Reference in new issue
Block a user