diff --git a/internal/grpc/services/gateway/storageprovider.go b/internal/grpc/services/gateway/storageprovider.go index 3ea0d881f4..da46ffbd8e 100644 --- a/internal/grpc/services/gateway/storageprovider.go +++ b/internal/grpc/services/gateway/storageprovider.go @@ -1945,7 +1945,10 @@ func (s *svc) getPath(ctx context.Context, ref *provider.Reference, keys ...stri if ref.ResourceId != nil { req := &provider.StatRequest{Ref: ref, ArbitraryMetadataKeys: keys} res, err := s.stat(ctx, req) - if (res != nil && res.Status.Code != rpc.Code_CODE_OK) || err != nil { + if err != nil { + return "", status.NewStatusFromErrType(ctx, "getPath ref="+ref.String(), err) + } + if res != nil && res.Status.Code != rpc.Code_CODE_OK { return "", res.Status } diff --git a/internal/http/services/owncloud/ocs/cache.go b/internal/http/services/owncloud/ocs/cache.go index 2db8e33702..ea587ae5fa 100644 --- a/internal/http/services/owncloud/ocs/cache.go +++ b/internal/http/services/owncloud/ocs/cache.go @@ -23,6 +23,7 @@ import ( "net/http" "net/http/httptest" + "github.com/cs3org/reva/pkg/appctx" ctxpkg "github.com/cs3org/reva/pkg/ctx" "google.golang.org/grpc/metadata" ) @@ -31,21 +32,33 @@ func (s *svc) cacheWarmup(w http.ResponseWriter, r *http.Request) { if s.warmupCacheTracker != nil { u := ctxpkg.ContextMustGetUser(r.Context()) tkn := ctxpkg.ContextMustGetToken(r.Context()) + log := appctx.GetLogger(r.Context()) ctx := context.Background() + ctx = appctx.WithLogger(ctx, log) ctx = ctxpkg.ContextSetUser(ctx, u) ctx = ctxpkg.ContextSetToken(ctx, tkn) ctx = metadata.AppendToOutgoingContext(ctx, ctxpkg.TokenHeader, tkn) - req := r.Clone(ctx) - req.Method = http.MethodGet + + req, _ := http.NewRequest("GET", "", nil) + req = req.WithContext(ctx) + req.URL = r.URL id := u.Id.OpaqueId if _, err := s.warmupCacheTracker.Get(id); err != nil { p := httptest.NewRecorder() _ = s.warmupCacheTracker.Set(id, true) + + log.Info().Msgf("cache warmup getting created shares for user %s", id) 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" + + log.Info().Msgf("cache warmup getting received shares for user %s", id) + req.URL.Path = "/v1.php/apps/files_sharing/api/v1/shares" + q := req.URL.Query() + q.Set("shared_with_me", "true") + q.Set("state", "all") + req.URL.RawQuery = q.Encode() s.router.ServeHTTP(p, req) } } diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index 47bc328efb..73167f35e8 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -100,7 +100,7 @@ func (h *Handler) Init(c *config.Config) { h.additionalInfoTemplate, _ = template.New("additionalInfo").Parse(c.AdditionalInfoAttribute) h.userIdentifierCache = ttlcache.NewCache() - _ = h.userIdentifierCache.SetTTL(time.Second * 60) + _ = h.userIdentifierCache.SetTTL(24 * time.Hour) if h.resourceInfoCacheTTL > 0 { cwm, err := getCacheWarmupManager(c) @@ -512,6 +512,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { // which pending state to list stateFilter := getStateFilter(r.FormValue("state")) + log := appctx.GetLogger(r.Context()) client, err := pool.GetGatewayServiceClient(h.gatewayAddr) if err != nil { response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error getting grpc gateway client", err) @@ -1022,6 +1023,7 @@ func (h *Handler) getResourceInfo(ctx context.Context, client gateway.GatewayAPI pinfo = infoIf.(*provider.ResourceInfo) status = &rpc.Status{Code: rpc.Code_CODE_OK} } else { + logger.Debug().Msgf("cache miss for resource %+v, statting", key) statReq := &provider.StatRequest{ Ref: ref, }