Skip to content

Commit

Permalink
For multi-source downsync/get the separator for paths is changed to |
Browse files Browse the repository at this point in the history
  • Loading branch information
DanEngelbrecht committed Apr 11, 2024
1 parent 2fd41d3 commit b36db38
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
##
- **CHANGED** For multi-source downsync/get the separator for paths is changed to | to avoid problems with path that contains spaces
- **FIXED** Network paths with spaces in them don't work - #252

## v0.4.2
- **FIXED** Networks share paths that starts with \\ no longer need to be manually escaped (fixes https://github.com/DanEngelbrecht/golongtail/issues/249)
- **UPDATED** Update longtaillib to v0.4.2

Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_downsync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func TestMultiVersionDownsync(t *testing.T) {
executeCommandLine("upsync", "--include-filter-regex", ".*/$**.*\\.layer2$", "--source-path", testPath+"/source", "--target-path", fsBlobPathPrefix+"/index/layer2.lvi", "--storage-uri", fsBlobPathPrefix+"/storage", "--version-local-store-index-path", fsBlobPathPrefix+"/index/layer2.lsi")
executeCommandLine("upsync", "--include-filter-regex", ".*/$**.*\\.layer3$", "--source-path", testPath+"/source", "--target-path", fsBlobPathPrefix+"/index/layer3.lvi", "--storage-uri", fsBlobPathPrefix+"/storage", "--version-local-store-index-path", fsBlobPathPrefix+"/index/layer3.lsi")

cmd, err := executeCommandLine("downsync", "--source-path", fsBlobPathPrefix+"/index/base.lvi "+fsBlobPathPrefix+"/index/layer2.lvi "+fsBlobPathPrefix+"/index/layer3.lvi", "--target-path", testPath+"/target", "--storage-uri", fsBlobPathPrefix+"/storage", "--version-local-store-index-path", fsBlobPathPrefix+"/index/base.lsi "+fsBlobPathPrefix+"/index/layer2.lsi "+fsBlobPathPrefix+"/index/layer3.lsi")
cmd, err := executeCommandLine("downsync", "--source-path", fsBlobPathPrefix+"/index/base.lvi|"+fsBlobPathPrefix+"/index/layer2.lvi|"+fsBlobPathPrefix+"/index/layer3.lvi", "--target-path", testPath+"/target", "--storage-uri", fsBlobPathPrefix+"/storage", "--version-local-store-index-path", fsBlobPathPrefix+"/index/base.lsi|"+fsBlobPathPrefix+"/index/layer2.lsi|"+fsBlobPathPrefix+"/index/layer3.lsi")
if err != nil {
t.Errorf("%s: %s", cmd, err)
}
Expand Down
2 changes: 1 addition & 1 deletion commands/cmd_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func get(
}

type GetCmd struct {
GetConfigURIs []string `name:"source-path" help:"File uri(s) for json formatted get-config file" required:"" sep:" "`
GetConfigURIs []string `name:"source-path" help:"File uri(s) for json formatted get-config file" required:"" sep:"|"`
S3EndpointResolverURLOption
TargetPathOption
TargetIndexUriOption
Expand Down
4 changes: 2 additions & 2 deletions commands/cmd_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestMultiVersionGet(t *testing.T) {
executeCommandLine("put", "--include-filter-regex", ".*/$**.*\\.layer2$", "--source-path", testPath+"/source", "--target-path", fsBlobPathPrefix+"/index/layer2.json", "--storage-uri", fsBlobPathPrefix+"/storage", "--version-local-store-index-path", fsBlobPathPrefix+"/index/layer2.lsi")
executeCommandLine("put", "--include-filter-regex", ".*/$**.*\\.layer3$", "--source-path", testPath+"/source", "--target-path", fsBlobPathPrefix+"/index/layer3.json", "--storage-uri", fsBlobPathPrefix+"/storage", "--version-local-store-index-path", fsBlobPathPrefix+"/index/layer3.lsi")

cmd, err := executeCommandLine("get", "--source-path", fsBlobPathPrefix+"/index/base.json "+fsBlobPathPrefix+"/index/layer2.json "+fsBlobPathPrefix+"/index/layer3.json", "--target-path", testPath+"/target")
cmd, err := executeCommandLine("get", "--source-path", fsBlobPathPrefix+"/index/base.json|"+fsBlobPathPrefix+"/index/layer2.json|"+fsBlobPathPrefix+"/index/layer3.json" , "--target-path", testPath+"/target")
if err != nil {
t.Errorf("%s: %s", cmd, err)
}
Expand All @@ -130,7 +130,7 @@ func TestMultiVersionGetMismatchStoreURI(t *testing.T) {
executeCommandLine("put", "--include-filter-regex", ".*/$**.*\\.layer2$", "--source-path", testPath+"/source", "--target-path", fsBlobPathPrefix+"/index/layer2.json", "--storage-uri", fsBlobPathPrefix+"/storage", "--version-local-store-index-path", fsBlobPathPrefix+"/index/layer2.lsi")
executeCommandLine("put", "--include-filter-regex", ".*/$**.*\\.layer3$", "--source-path", testPath+"/source", "--target-path", fsBlobPathPrefix+"/index/layer3.json", "--storage-uri", fsBlobPathPrefix+"/bad_storage", "--version-local-store-index-path", fsBlobPathPrefix+"/index/layer3.lsi")

cmd, err := executeCommandLine("get", "--source-path", fsBlobPathPrefix+"/index/base.json "+fsBlobPathPrefix+"/index/layer2.json "+fsBlobPathPrefix+"/index/layer3.json", "--target-path", testPath+"/target")
cmd, err := executeCommandLine("get", "--source-path", fsBlobPathPrefix+"/index/base.json|"+fsBlobPathPrefix+"/index/layer2.json|"+fsBlobPathPrefix+"/index/layer3.json", "--target-path", testPath+"/target")
if err == nil {
t.Errorf("%s: %s", cmd, err)
}
Expand Down
9 changes: 9 additions & 0 deletions commands/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@ import (

"github.com/DanEngelbrecht/golongtail/longtailstorelib"
"github.com/alecthomas/kong"
"github.com/sirupsen/logrus"
)

func executeCommandLine(command string, params ...string) (string, error) {
log := logrus.WithFields(logrus.Fields{
"command": command,
"params": params,
})

args := []string{command}
args = append(args, params...)

log.Info("++++++ running command")

// args := strings.Split(commandLine, " ")
parser, err := kong.New(&Cli)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions commands/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type SourceUriOption struct {
}

type MultiSourceUrisOption struct {
SourcePaths []string `name:"source-path" help:"Source file uri(s)" required:"" sep:" "`
SourcePaths []string `name:"source-path" help:"Source file uri(s)" required:"" sep:"|"`
}

type ValidateTargetOption struct {
Expand All @@ -73,7 +73,7 @@ type VersionLocalStoreIndexPathOption struct {
}

type MultiVersionLocalStoreIndexPathsOption struct {
VersionLocalStoreIndexPaths []string `name:"version-local-store-index-path" help:"Path(s) to an optimized store index matching the source. If any of the file(s) cant be read it will fall back to the master store index" sep:" "`
VersionLocalStoreIndexPaths []string `name:"version-local-store-index-path" help:"Path(s) to an optimized store index matching the source. If any of the file(s) cant be read it will fall back to the master store index" sep:"|"`
}

type VersionIndexPathOption struct {
Expand Down

0 comments on commit b36db38

Please sign in to comment.