From 17181b90489318c18fd071c96e412d236fad7e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 22 Sep 2022 08:43:04 +0000 Subject: [PATCH] also invalidate cache if events are disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- pkg/rhttp/datatx/manager/tus/tus.go | 43 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/pkg/rhttp/datatx/manager/tus/tus.go b/pkg/rhttp/datatx/manager/tus/tus.go index 975b1f6881..92904ac808 100644 --- a/pkg/rhttp/datatx/manager/tus/tus.go +++ b/pkg/rhttp/datatx/manager/tus/tus.go @@ -96,10 +96,9 @@ func (m *manager) Handler(fs storage.FS) (http.Handler, error) { // let the composable storage tell tus which extensions it supports composable.UseIn(composer) - publishEvents := m.publisher != nil config := tusd.Config{ StoreComposer: composer, - NotifyCompleteUploads: publishEvents, + NotifyCompleteUploads: true, } handler, err := tusd.NewUnroutedHandler(config) @@ -107,30 +106,30 @@ func (m *manager) Handler(fs storage.FS) (http.Handler, error) { return nil, err } - if publishEvents { - go func() { - for { - ev := <-handler.CompleteUploads - info := ev.Upload - owner := &userv1beta1.UserId{ - Idp: info.Storage["Idp"], - OpaqueId: info.Storage["UserId"], - } - ref := &provider.Reference{ - ResourceId: &provider.ResourceId{ - StorageId: info.MetaData["providerID"], - SpaceId: info.Storage["SpaceRoot"], - OpaqueId: info.Storage["SpaceRoot"], - }, - Path: utils.MakeRelativePath(filepath.Join(info.MetaData["dir"], info.MetaData["filename"])), - } - datatx.InvalidateCache(owner, ref, m.statCache) + go func() { + for { + ev := <-handler.CompleteUploads + info := ev.Upload + owner := &userv1beta1.UserId{ + Idp: info.Storage["Idp"], + OpaqueId: info.Storage["UserId"], + } + ref := &provider.Reference{ + ResourceId: &provider.ResourceId{ + StorageId: info.MetaData["providerID"], + SpaceId: info.Storage["SpaceRoot"], + OpaqueId: info.Storage["SpaceRoot"], + }, + Path: utils.MakeRelativePath(filepath.Join(info.MetaData["dir"], info.MetaData["filename"])), + } + datatx.InvalidateCache(owner, ref, m.statCache) + if m.publisher != nil { if err := datatx.EmitFileUploadedEvent(owner, ref, m.publisher); err != nil { appctx.GetLogger(context.Background()).Error().Err(err).Msg("failed to publish FileUploaded event") } } - }() - } + } + }() h := handler.Middleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { method := r.Method