Skip to content

Commit

Permalink
Fix bug where FileMapper output was being overwritten in every loop
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeckman314 committed Sep 25, 2024
1 parent 590a3e3 commit 2ec10d8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ git_upstream := $(shell git remote get-url $(shell git config branch.$(shell git
export GIT_BRANCH = $(git_branch)
export GIT_UPSTREAM = $(git_upstream)

export FUNNEL_VERSION=0.11.1-rc.4
export FUNNEL_VERSION=0.11.1-rc.5

# LAST_PR_NUMBER is used by the release notes builder to generate notes
# based on pull requests (PR) up until the last release.
Expand Down
49 changes: 25 additions & 24 deletions worker/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,38 +250,39 @@ func fixLinks(mapper *FileMapper, basepath string) {
}

// resolveWildcards resolves any wildcards/globs in the output paths.
func resolveWildcards(mapper *FileMapper, output *tes.Output) error {
func resolveWildcards(mapper *FileMapper) error {
var outputs []*tes.Output

// If path contains a wildcard, handle globbing and upload each file individually
if strings.Contains(output.Path, "*") {
globs, err := filepath.Glob(output.Path)
if err != nil {
return fmt.Errorf("failed to resolve path %v: %v", output.Path, err)
}

for _, glob := range globs {
out := proto.Clone(output).(*tes.Output)
out.Path = glob

// Construct URL by:
// - removing the mapper.WorkDir from the output.Path
// - then removing the PathPrefix
// - then joining the output.URL
globPath := strings.TrimPrefix(glob, mapper.WorkDir)
fixPath := strings.TrimPrefix(globPath, output.PathPrefix)
out.Url, err = url.JoinPath(output.Url, fixPath)
for _, output := range mapper.Outputs {
// If path contains a wildcard, handle globbing and upload each file individually
if strings.Contains(output.Path, "*") {
globs, err := filepath.Glob(output.Path)
if err != nil {
return fmt.Errorf("failed to join URL: %v", err)
return fmt.Errorf("failed to resolve path %v: %v", output.Path, err)
}

outputs = append(outputs, out)
for _, glob := range globs {
out := proto.Clone(output).(*tes.Output)
out.Path = glob

// Construct URL by:
// - removing the mapper.WorkDir from the output.Path
// - then removing the PathPrefix
// - then joining the output.URL
globPath := strings.TrimPrefix(glob, mapper.WorkDir)
fixPath := strings.TrimPrefix(globPath, output.PathPrefix)
out.Url, err = url.JoinPath(output.Url, fixPath)
if err != nil {
return fmt.Errorf("failed to join URL: %v", err)
}

outputs = append(outputs, out)
}
} else {
outputs = append(outputs, output)
}
} else {
outputs = append(outputs, output)
}

mapper.Outputs = outputs

return nil
}
4 changes: 1 addition & 3 deletions worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,7 @@ func (r *DefaultWorker) Run(pctx context.Context) (runerr error) {

if run.ok() {
// Resolve wildcards in the output paths
for _, output := range mapper.Outputs {
resolveWildcards(mapper, output)
}
resolveWildcards(mapper)
}

if run.ok() && r.Conf.ScratchPath != "" {
Expand Down

0 comments on commit 2ec10d8

Please sign in to comment.