Skip to content

Commit

Permalink
MB-43969 fixing backup endpoint on bucket not available on windows.
Browse files Browse the repository at this point in the history
filepath.Clean is changing path seperator as per OS and hence furher logic to split path based on '/' fails.

Change-Id: Iff4c86813809bffa41fb429f085dae604581b02e
  • Loading branch information
Yogendra Acharya committed Feb 24, 2021
1 parent a29e83c commit caf8f74
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion secondary/cmd/indexer/main.go
Expand Up @@ -16,7 +16,7 @@ import (

"github.com/couchbase/cbauth"
"github.com/couchbase/indexing/secondary/common"
"github.com/couchbase/indexing/secondary/fdb"
forestdb "github.com/couchbase/indexing/secondary/fdb"
"github.com/couchbase/indexing/secondary/indexer"
"github.com/couchbase/indexing/secondary/logging"
"github.com/couchbase/indexing/secondary/platform"
Expand Down
25 changes: 15 additions & 10 deletions secondary/indexer/api.go
@@ -1,15 +1,18 @@
package indexer

import "net/http"
import "strings"
import re "regexp"
import "path/filepath"
import "fmt"
import (
"net/http"
"strings"

import log "github.com/couchbase/indexing/secondary/logging"
import c "github.com/couchbase/indexing/secondary/common"
import "github.com/couchbase/indexing/secondary/manager"
import "github.com/couchbase/cbauth"
"fmt"
re "regexp"

log "github.com/couchbase/indexing/secondary/logging"

"github.com/couchbase/cbauth"
c "github.com/couchbase/indexing/secondary/common"
"github.com/couchbase/indexing/secondary/manager"
)

type target struct {
version string
Expand Down Expand Up @@ -71,7 +74,7 @@ func (api *restServer) routeRequest(
if !ok {
return
}
url := filepath.Clean(r.URL.Path) // Remove trailing space
url := strings.TrimSpace(r.URL.Path) // Remove trailing space.
segs := strings.Split(url, "/")
var req request
var handler reqHandler
Expand All @@ -84,6 +87,7 @@ func (api *restServer) routeRequest(
version := segs[2]
segs = append(segs[:2], segs[3:]...)
url = strings.Join(segs, "/")

req = request{
w: w,
r: r,
Expand All @@ -96,6 +100,7 @@ func (api *restServer) routeRequest(
} else { // Use the default version
segs := strings.Split(url, "/")
if fun, ok := staticRoutes[segs[2]]; ok {

req = request{
w: w,
r: r,
Expand Down
3 changes: 1 addition & 2 deletions secondary/manager/request_handler.go
Expand Up @@ -19,7 +19,6 @@ import (
"net/http"
"os"
"path"
"path/filepath"
"runtime/debug"
"sort"
"strconv"
Expand Down Expand Up @@ -3037,7 +3036,7 @@ func (m *requestHandlerContext) authorizeBucketRequest(w http.ResponseWriter,
}

func (m *requestHandlerContext) bucketReqHandler(w http.ResponseWriter, r *http.Request, creds cbauth.Creds) {
url := filepath.Clean(r.URL.Path)
url := strings.TrimSpace(r.URL.Path)
logging.Debugf("bucketReqHandler: url %v", url)

segs := strings.Split(url, "/")
Expand Down

0 comments on commit caf8f74

Please sign in to comment.