Skip to content

Commit

Permalink
Add cross-version remapped merges to xl-meta (minio#19765)
Browse files Browse the repository at this point in the history
Adds `-xver` which can be used with `-export` and `-combine` to attempt to combine files across versions if data is suspected to be the same. Overlapping data is compared.

Bonus: Make `inspect` accept wildcards.
  • Loading branch information
klauspost authored May 19, 2024
1 parent 1fd90c9 commit 2c7bcee
Show file tree
Hide file tree
Showing 4 changed files with 409 additions and 55 deletions.
1 change: 1 addition & 0 deletions docs/debugging/inspect/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.19

require (
github.com/klauspost/compress v1.17.4
github.com/klauspost/filepathx v1.1.1
github.com/minio/colorjson v1.0.6
github.com/minio/madmin-go/v3 v3.0.36
github.com/secure-io/sio-go v0.3.1
Expand Down
2 changes: 2 additions & 0 deletions docs/debugging/inspect/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/klauspost/filepathx v1.1.1 h1:201zvAsL1PhZvmXTP+QLer3AavWrO3U1NILWpniHK4w=
github.com/klauspost/filepathx v1.1.1/go.mod h1:XWxdp8rEw4gupPBrxrV5Q57dL/71xj0OgV1gKt2zTfU=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
Expand Down
20 changes: 17 additions & 3 deletions docs/debugging/inspect/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (
"os"
"strings"
"time"

"github.com/klauspost/filepathx"
)

var (
Expand Down Expand Up @@ -68,7 +70,7 @@ func main() {
}
}

var inputFileName, outputFileName string
var inputs []string

// Parse parameters
switch {
Expand All @@ -83,22 +85,34 @@ func main() {
fatalErr(err)
}
fatalErr(json.Unmarshal(got, &input))
inputFileName = input.File
inputs = []string{input.File}
*keyHex = input.Key
case len(flag.Args()) == 1:
inputFileName = flag.Args()[0]
var err error
inputs, err = filepathx.Glob(flag.Args()[0])
fatalErr(err)
default:
flag.Usage()
fatalIf(true, "Only 1 file can be decrypted")
os.Exit(1)
}
for _, input := range inputs {
processFile(input, privateKey)
}
}

func processFile(inputFileName string, privateKey []byte) {
// Calculate the output file name
var outputFileName string
switch {
case strings.HasSuffix(inputFileName, ".enc"):
outputFileName = strings.TrimSuffix(inputFileName, ".enc") + ".zip"
case strings.HasSuffix(inputFileName, ".zip"):
outputFileName = strings.TrimSuffix(inputFileName, ".zip") + ".decrypted.zip"
case strings.Contains(inputFileName, ".enc."):
outputFileName = strings.Replace(inputFileName, ".enc.", ".", 1) + ".zip"
default:
outputFileName = inputFileName + ".decrypted"
}

// Backup any already existing output file
Expand Down
Loading

0 comments on commit 2c7bcee

Please sign in to comment.