Skip to content

Commit

Permalink
Trim file paths for non-global path cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Nov 15, 2021
1 parent 963ec06 commit 7c9b10c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/http/services/owncloud/ocdav/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"encoding/xml"
"io"
"net/http"
"path/filepath"

rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
Expand Down Expand Up @@ -105,6 +106,19 @@ func (s *svc) doFilterFiles(w http.ResponseWriter, r *http.Request, ff *reportFi
log.Error().Interface("stat_response", statRes).Msg("error getting resource info")
continue
}

// If global URLs are not supported, return only the file path
if s.c.WebdavNamespace != "" {
// The paths we receive have the format /user/<username>/<filepath>
// We only want the `<filepath>` part. Thus we remove the /user/<username>/ part.
rel, err := filepath.Rel(namespace, statRes.Info.Path)
if err != nil {
log.Error().Err(err).Msg("path doesn't have the expected format")
continue
}
statRes.Info.Path = filepath.Join("/", rel)
}

infos = append(infos, statRes.Info)
}

Expand Down

0 comments on commit 7c9b10c

Please sign in to comment.