Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Oct 21, 2021
1 parent 8ee808f commit 7dc5201
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
14 changes: 7 additions & 7 deletions internal/http/services/owncloud/ocs/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

func (s *svc) cacheWarmup(w http.ResponseWriter, r *http.Request) {
if s.warmupCache != nil {
if s.warmupCacheTracker != nil {
u := ctxpkg.ContextMustGetUser(r.Context())
tkn := ctxpkg.ContextMustGetToken(r.Context())

Expand All @@ -40,13 +40,13 @@ func (s *svc) cacheWarmup(w http.ResponseWriter, r *http.Request) {
req.Method = http.MethodGet

id := u.Id.OpaqueId
if _, err := s.warmupCache.Get(id); err != nil {
if _, err := s.warmupCacheTracker.Get(id); err != nil {
p := httptest.NewRecorder()
_ = s.warmupCache.Set(id, true)
req.URL.Path = "/apps/files_sharing/api/v1/shares"
go s.router.ServeHTTP(p, req)
req.URL.Path = "/apps/files_sharing/api/v1/shares?shared_with_me=true"
go s.router.ServeHTTP(p, req)
_ = s.warmupCacheTracker.Set(id, true)
req.URL.Path = "/v1.php/apps/files_sharing/api/v1/shares"
s.router.ServeHTTP(p, req)
req.URL.Path = "/v1.php/apps/files_sharing/api/v1/shares?shared_with_me=true"
s.router.ServeHTTP(p, req)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,11 @@ func (h *Handler) ListShares(w http.ResponseWriter, r *http.Request) {
response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error mapping share data", err)
}
if listSharedWithMe {
h.ListSharesWithMe(w, r)
h.listSharesWithMe(w, r)
return
}
}
h.ListSharesWithOthers(w, r)
h.listSharesWithOthers(w, r)
}

const (
Expand All @@ -508,8 +508,7 @@ const (
ocsStateRejected = 2
)

// ListSharesWithMe returns the shares receieved by the user present in the context
func (h *Handler) ListSharesWithMe(w http.ResponseWriter, r *http.Request) {
func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) {
// which pending state to list
stateFilter := getStateFilter(r.FormValue("state"))

Expand Down Expand Up @@ -706,9 +705,7 @@ func findMatch(shareJailInfos []*provider.ResourceInfo, id *provider.ResourceId)
return nil
}

// ListSharesWithOthers returns the public, user, group and federated shares
// created by the user present in the context
func (h *Handler) ListSharesWithOthers(w http.ResponseWriter, r *http.Request) {
func (h *Handler) listSharesWithOthers(w http.ResponseWriter, r *http.Request) {
shares := make([]*conversions.ShareData, 0)

filters := []*collaboration.Filter{}
Expand Down
12 changes: 6 additions & 6 deletions internal/http/services/owncloud/ocs/ocs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func init() {
}

type svc struct {
c *config.Config
router *chi.Mux
warmupCache *ttlcache.Cache
c *config.Config
router *chi.Mux
warmupCacheTracker *ttlcache.Cache
}

func New(m map[string]interface{}, log *zerolog.Logger) (global.Service, error) {
Expand All @@ -67,8 +67,8 @@ func New(m map[string]interface{}, log *zerolog.Logger) (global.Service, error)
}

if conf.CacheWarmupDriver == "first-request" && conf.ResourceInfoCacheTTL > 0 {
s.warmupCache = ttlcache.NewCache()
_ = s.warmupCache.SetTTL(time.Second * time.Duration(conf.ResourceInfoCacheTTL))
s.warmupCacheTracker = ttlcache.NewCache()
_ = s.warmupCacheTracker.SetTTL(time.Second * time.Duration(conf.ResourceInfoCacheTTL))
}

return s, nil
Expand Down Expand Up @@ -148,7 +148,7 @@ func (s *svc) Handler() http.Handler {
log.Debug().Str("path", r.URL.Path).Msg("ocs routing")

// Warmup the share cache for the user
s.cacheWarmup(w, r)
go s.cacheWarmup(w, r)

// unset raw path, otherwise chi uses it to route and then fails to match percent encoded path segments
r.URL.RawPath = ""
Expand Down
3 changes: 0 additions & 3 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1771,9 +1771,6 @@ func getResourceType(isDir bool) provider.ResourceType {
}

func (fs *eosfs) extractUIDAndGID(u *userpb.User) (eosclient.Authorization, error) {
if u.Id.OpaqueId == "root" {
return eosclient.Authorization{Role: eosclient.Role{UID: "0", GID: "0"}}, nil
}
if u.UidNumber == 0 {
return eosclient.Authorization{}, errors.New("eosfs: uid missing for user")
}
Expand Down

0 comments on commit 7dc5201

Please sign in to comment.