From c4d462050d1fdb84ac868e8636e6e50dce5ad767 Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Wed, 3 Nov 2021 15:35:53 +0100 Subject: [PATCH] Add check for whether cache is not nil --- .../ocs/handlers/apps/sharing/shares/shares.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 db979035b6..ad295898de 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 @@ -1051,10 +1051,15 @@ func (h *Handler) getResourceInfo(ctx context.Context, client gateway.GatewayAPI var pinfo *provider.ResourceInfo var status *rpc.Status var err error - if pinfo, err = h.resourceInfoCache.Get(key); h.resourceInfoCacheTTL > 0 && err == nil { - logger.Debug().Msgf("cache hit for resource %+v", key) - status = &rpc.Status{Code: rpc.Code_CODE_OK} - } else { + var foundInCache bool + if h.resourceInfoCacheTTL > 0 && h.resourceInfoCache != nil { + if pinfo, err = h.resourceInfoCache.Get(key); err == nil { + logger.Debug().Msgf("cache hit for resource %+v", key) + status = &rpc.Status{Code: rpc.Code_CODE_OK} + foundInCache = true + } + } + if !foundInCache { logger.Debug().Msgf("cache miss for resource %+v, statting", key) statReq := &provider.StatRequest{ Ref: ref,