Skip to content

Commit

Permalink
chore(deps): Bumping absto to handle missing directory for s3
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Mar 18, 2023
1 parent a216bfd commit f2aa5aa
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 151 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/ViBiOh/ChatPotte v0.2.29
github.com/ViBiOh/absto v1.3.2
github.com/ViBiOh/absto v1.4.0
github.com/ViBiOh/auth/v2 v2.14.23
github.com/ViBiOh/exas v0.6.0
github.com/ViBiOh/flags v1.2.0
Expand Down Expand Up @@ -33,7 +33,7 @@ require (
github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.16.0 // indirect
github.com/klauspost/compress v1.16.3 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/ViBiOh/ChatPotte v0.2.29 h1:8cIZDvkTfKOC4bZaQkxyOM47BcXZQR8ykJPl9LsZpMM=
github.com/ViBiOh/ChatPotte v0.2.29/go.mod h1:GXEpgMQkN0R3CHpqVbuMhS8F6U1S/Qb7qQJ2juFqTtc=
github.com/ViBiOh/absto v1.3.2 h1:JZ6RJYh9YABO1QHfPcSjb/fEMjqcPcT59kH/jOr22Ys=
github.com/ViBiOh/absto v1.3.2/go.mod h1:RXbNesRB3Q9BWMxLeT3DXX29bhk5Tqifo2gssPtQVnk=
github.com/ViBiOh/absto v1.4.0 h1:fXaP7CbgQ/cJAfKM8Ksc6IlXkjWn6Dz6n9U6KHaQ5WA=
github.com/ViBiOh/absto v1.4.0/go.mod h1:PInUcncKy3FVbFkh2j2IvYJ906JS7HRMUEq+dArLSnw=
github.com/ViBiOh/auth/v2 v2.14.23 h1:ZeQ2/tsh4Z3Jcu/y9R4X05uyhBUJeUC6UN8XyaKJ2s4=
github.com/ViBiOh/auth/v2 v2.14.23/go.mod h1:pIMuBueO3sknvnvfAFJBOxTjoGWuxke6lp1ZSh6478w=
github.com/ViBiOh/exas v0.6.0 h1:UWQuzesHShBSMkQw7mWAj4NBwL1Hb/fDcgzk/UpacYQ=
Expand Down Expand Up @@ -175,8 +175,8 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4=
github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/compress v1.16.3 h1:XuJt9zzcnaz6a16/OU53ZjWp/v7/42WcR5t2a0PcNQY=
github.com/klauspost/compress v1.16.3/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
Expand Down
3 changes: 1 addition & 2 deletions pkg/crud/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net/http"

"github.com/ViBiOh/fibr/pkg/provider"
"github.com/ViBiOh/httputils/v4/pkg/cntxt"
"github.com/ViBiOh/httputils/v4/pkg/model"
"github.com/ViBiOh/httputils/v4/pkg/renderer"
)
Expand Down Expand Up @@ -47,7 +46,7 @@ func (a App) Delete(w http.ResponseWriter, r *http.Request, request provider.Req
provider.SetPrefsCookie(w, request)
}

go a.notify(cntxt.WithoutDeadline(ctx), provider.NewDeleteEvent(request, info, a.rendererApp))
go a.pushEvent(provider.NewDeleteEvent(ctx, request, info, a.rendererApp))

a.rendererApp.Redirect(w, r, fmt.Sprintf("?d=%s", request.Display), renderer.NewSuccessMessage("%s successfully deleted", info.Name))
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/crud/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/ViBiOh/fibr/pkg/geo"
"github.com/ViBiOh/fibr/pkg/metadata"
"github.com/ViBiOh/fibr/pkg/provider"
"github.com/ViBiOh/httputils/v4/pkg/cntxt"
"github.com/ViBiOh/httputils/v4/pkg/logger"
"github.com/ViBiOh/httputils/v4/pkg/model"
"github.com/ViBiOh/httputils/v4/pkg/query"
Expand Down Expand Up @@ -75,7 +74,7 @@ func (a App) handleFile(w http.ResponseWriter, r *http.Request, request provider
if query.GetBool(r, "browser") {
provider.SetPrefsCookie(w, request)

go a.notify(cntxt.WithoutDeadline(r.Context()), provider.NewAccessEvent(item, r))
go a.pushEvent(provider.NewAccessEvent(r.Context(), item, r))

return a.browse(r.Context(), request, item, message)
}
Expand Down Expand Up @@ -132,7 +131,7 @@ func (a App) handleDir(w http.ResponseWriter, r *http.Request, request provider.
return errorReturn(request, err)
}

go a.notify(cntxt.WithoutDeadline(r.Context()), provider.NewAccessEvent(item, r))
go a.pushEvent(provider.NewAccessEvent(r.Context(), item, r))

if query.GetBool(r, "search") {
return a.search(r, request, item, items)
Expand Down
3 changes: 1 addition & 2 deletions pkg/crud/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"strings"

"github.com/ViBiOh/fibr/pkg/provider"
"github.com/ViBiOh/httputils/v4/pkg/cntxt"
"github.com/ViBiOh/httputils/v4/pkg/model"
"github.com/ViBiOh/httputils/v4/pkg/renderer"
)
Expand Down Expand Up @@ -175,7 +174,7 @@ func (a App) handlePostDescription(w http.ResponseWriter, r *http.Request, reque
return
}

go a.notify(cntxt.WithoutDeadline(ctx), provider.NewDescriptionEvent(item, a.bestSharePath(item.Pathname), description, a.rendererApp))
go a.pushEvent(provider.NewDescriptionEvent(ctx, item, a.bestSharePath(item.Pathname), description, a.rendererApp))

a.rendererApp.Redirect(w, r, fmt.Sprintf("?d=%s#%s", request.Display, item.ID), renderer.NewSuccessMessage("Description successfully edited"))
}
Expand Down
21 changes: 0 additions & 21 deletions pkg/crud/push.go

This file was deleted.

4 changes: 2 additions & 2 deletions pkg/crud/regenerate.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (a App) regenerate(w http.ResponseWriter, r *http.Request, request provider
if item.IsDir {
directories = append(directories, item)
} else {
a.notify(ctx, provider.NewRestartEvent(item, subset))
a.pushEvent(provider.NewRestartEvent(ctx, item, subset))
}

return nil
Expand All @@ -52,7 +52,7 @@ func (a App) regenerate(w http.ResponseWriter, r *http.Request, request provider
}

for _, directory := range directories {
a.notify(ctx, provider.NewStartEvent(directory))
a.pushEvent(provider.NewStartEvent(ctx, directory))
}
}(cntxt.WithoutDeadline(ctx))

Expand Down
3 changes: 1 addition & 2 deletions pkg/crud/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

absto "github.com/ViBiOh/absto/pkg/model"
"github.com/ViBiOh/fibr/pkg/provider"
"github.com/ViBiOh/httputils/v4/pkg/cntxt"
"github.com/ViBiOh/httputils/v4/pkg/model"
"github.com/ViBiOh/httputils/v4/pkg/renderer"
)
Expand All @@ -24,7 +23,7 @@ func (a App) DoRename(ctx context.Context, oldPath, newPath string, oldItem abst
return absto.Item{}, fmt.Errorf("get info of new item: %w", err)
}

go a.notify(cntxt.WithoutDeadline(ctx), provider.NewRenameEvent(oldItem, newItem, a.bestSharePath(newPath), a.rendererApp))
go a.pushEvent(provider.NewRenameEvent(ctx, oldItem, newItem, a.bestSharePath(newPath), a.rendererApp))

return newItem, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/crud/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (a App) saveUploadedFile(ctx context.Context, request provider.Request, inp
if info, infoErr := a.storageApp.Info(ctx, filePath); infoErr != nil {
logger.Error("get info for upload event: %s", infoErr)
} else {
a.notify(ctx, provider.NewUploadEvent(request, info, a.bestSharePath(filePath), a.rendererApp))
a.pushEvent(provider.NewUploadEvent(ctx, request, info, a.bestSharePath(filePath), a.rendererApp))
}
}(cntxt.WithoutDeadline(ctx))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/crud/upload_chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (a App) mergeChunk(w http.ResponseWriter, r *http.Request, request provider
if info, infoErr := a.storageApp.Info(ctx, filePath); infoErr != nil {
logger.Error("get info for upload event: %s", infoErr)
} else {
a.notify(ctx, provider.NewUploadEvent(request, info, a.bestSharePath(filePath), a.rendererApp))
a.pushEvent(provider.NewUploadEvent(ctx, request, info, a.bestSharePath(filePath), a.rendererApp))
}
}(cntxt.WithoutDeadline(ctx))
}
Expand Down
61 changes: 33 additions & 28 deletions pkg/provider/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"path"
Expand All @@ -22,7 +21,7 @@ import (

type EventType uint

type EventProducer func(Event) error
type EventProducer func(Event)

type EventConsumer func(context.Context, Event)

Expand Down Expand Up @@ -167,11 +166,12 @@ func (e Event) GetTo() string {
return newName
}

func NewUploadEvent(request Request, item absto.Item, shareableURL string, rendererApp renderer.App) Event {
func NewUploadEvent(ctx context.Context, request Request, item absto.Item, shareableURL string, rendererApp renderer.App) Event {
return Event{
Time: time.Now(),
Type: UploadEvent,
Item: item,
TraceLink: trace.LinkFromContext(ctx),
URL: rendererApp.PublicURL(request.AbsoluteURL(item.Name)),
ShareableURL: rendererApp.PublicURL(shareableURL),
Metadata: map[string]string{
Expand All @@ -180,22 +180,24 @@ func NewUploadEvent(request Request, item absto.Item, shareableURL string, rende
}
}

func NewRenameEvent(old, new absto.Item, shareableURL string, rendererApp renderer.App) Event {
func NewRenameEvent(ctx context.Context, old, new absto.Item, shareableURL string, rendererApp renderer.App) Event {
return Event{
Time: time.Now(),
Type: RenameEvent,
Item: old,
TraceLink: trace.LinkFromContext(ctx),
New: &new,
URL: rendererApp.PublicURL(new.Pathname),
ShareableURL: rendererApp.PublicURL(shareableURL),
}
}

func NewDescriptionEvent(item absto.Item, shareableURL string, description string, rendererApp renderer.App) Event {
func NewDescriptionEvent(ctx context.Context, item absto.Item, shareableURL string, description string, rendererApp renderer.App) Event {
return Event{
Time: time.Now(),
Type: DescriptionEvent,
Item: item,
TraceLink: trace.LinkFromContext(ctx),
URL: rendererApp.PublicURL(item.Pathname),
ShareableURL: rendererApp.PublicURL(shareableURL),
Metadata: map[string]string{
Expand All @@ -204,35 +206,38 @@ func NewDescriptionEvent(item absto.Item, shareableURL string, description strin
}
}

func NewDeleteEvent(request Request, item absto.Item, rendererApp renderer.App) Event {
func NewDeleteEvent(ctx context.Context, request Request, item absto.Item, rendererApp renderer.App) Event {
return Event{
Time: time.Now(),
Type: DeleteEvent,
Item: item,
URL: rendererApp.PublicURL(request.AbsoluteURL("")),
Time: time.Now(),
Type: DeleteEvent,
Item: item,
TraceLink: trace.LinkFromContext(ctx),
URL: rendererApp.PublicURL(request.AbsoluteURL("")),
}
}

func NewStartEvent(item absto.Item) Event {
func NewStartEvent(ctx context.Context, item absto.Item) Event {
return Event{
Time: time.Now(),
Type: StartEvent,
Item: item,
Time: time.Now(),
Type: StartEvent,
Item: item,
TraceLink: trace.LinkFromContext(ctx),
}
}

func NewRestartEvent(item absto.Item, subset string) Event {
func NewRestartEvent(ctx context.Context, item absto.Item, subset string) Event {
return Event{
Time: time.Now(),
Type: StartEvent,
Item: item,
Time: time.Now(),
Type: StartEvent,
Item: item,
TraceLink: trace.LinkFromContext(ctx),
Metadata: map[string]string{
"force": subset,
},
}
}

func NewAccessEvent(item absto.Item, r *http.Request) Event {
func NewAccessEvent(ctx context.Context, item absto.Item, r *http.Request) Event {
metadata := make(map[string]string)
for key, values := range r.Header {
if strings.EqualFold(key, "Authorization") {
Expand All @@ -246,11 +251,12 @@ func NewAccessEvent(item absto.Item, r *http.Request) Event {
metadata["URL"] = r.URL.String()

return Event{
Time: time.Now(),
Type: AccessEvent,
Item: item,
Metadata: metadata,
URL: r.URL.String(),
Time: time.Now(),
Type: AccessEvent,
Item: item,
TraceLink: trace.LinkFromContext(ctx),
Metadata: metadata,
URL: r.URL.String(),
}
}

Expand Down Expand Up @@ -298,21 +304,20 @@ func (e EventBus) Done() <-chan struct{} {
return e.done
}

func (e EventBus) Push(event Event) error {
func (e EventBus) Push(event Event) {
select {
case <-e.closed:
e.increaseMetric(event, "refused")
return errors.New("bus is closed")
logger.Error("bus is closed")
default:
}

select {
case <-e.closed:
e.increaseMetric(event, "refused")
return errors.New("bus is closed")
logger.Error("bus is closed")
case e.bus <- event:
e.increaseMetric(event, "push")
return nil
}
}

Expand Down
21 changes: 0 additions & 21 deletions pkg/sanitizer/notify.go

This file was deleted.

Loading

0 comments on commit f2aa5aa

Please sign in to comment.