Skip to content

Commit

Permalink
fix: [CI-13388]: revert recurring key fix (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhay084 authored Jul 11, 2024
1 parent 49b2a9e commit c02cf0d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
23 changes: 6 additions & 17 deletions storage/backend/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"io"
"net/http"
"runtime"
"strings"

"github.com/meltwater/drone-cache/internal"
Expand Down Expand Up @@ -211,25 +210,15 @@ func (b *Backend) List(ctx context.Context, p string) ([]common.FileEntry, error
return nil, fmt.Errorf("failed to iterate objects present at path %s/%s with err: %v",
b.bucket, p, err)
}
// Check if the object matches the given prefix exactly or is within the prefix "directory"
if strings.HasPrefix(attrs.Name, p+GetSeparator()) {
entries = append(entries, common.FileEntry{
Path: attrs.Name,
Size: attrs.Size,
LastModified: attrs.Updated,
})
}
}

return entries, nil
}

func GetSeparator() string {
if runtime.GOOS == "windows" {
return `\`
entries = append(entries, common.FileEntry{
Path: attrs.Name,
Size: attrs.Size,
LastModified: attrs.Updated,
})
}

return "/"
return entries, nil
}

// Helpers
Expand Down
2 changes: 1 addition & 1 deletion storage/backend/gcs/gcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestRoundTrip(t *testing.T) {

entries, err := backend.List(context.TODO(), "")
test.Ok(t, err)
test.Equals(t, 0, len(entries))
test.Equals(t, 1, len(entries))
}

// Helpers
Expand Down

0 comments on commit c02cf0d

Please sign in to comment.