Add cross-version remapped merges to xl-meta (#19765)

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.
This commit is contained in:
Klaus Post
2024-05-19 08:31:54 -07:00
committed by GitHub
parent 1fd90c93ff
commit 2c7bcee53f
4 changed files with 409 additions and 55 deletions

View File

@@ -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

View File

@@ -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=

View File

@@ -31,6 +31,8 @@ import (
"os"
"strings"
"time"
"github.com/klauspost/filepathx"
)
var (
@@ -68,7 +70,7 @@ func main() {
}
}
var inputFileName, outputFileName string
var inputs []string
// Parse parameters
switch {
@@ -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