Skip to content

Commit

Permalink
fix(log): Fixing log placeholder and leaking path in thumbnail
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Aug 29, 2023
1 parent ae395db commit 3e45295
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pkg/metadata/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ func (s Service) EventConsumer(ctx context.Context, e provider.Event) {
switch e.Type {
case provider.StartEvent:
if err = s.handleStartEvent(ctx, e); err != nil {
getEventLogger(e.Item).Error("start: %s", err)
getEventLogger(e.Item).Error("start", "err", err)
}
case provider.UploadEvent:
if err = s.handleUploadEvent(ctx, e.Item, true); err != nil {
getEventLogger(e.Item).Error("upload: %s", err)
getEventLogger(e.Item).Error("upload", "err", err)
}
case provider.RenameEvent:
if !e.Item.IsDir() {
Expand All @@ -34,11 +34,11 @@ func (s Service) EventConsumer(ctx context.Context, e provider.Event) {
}

if err != nil {
getEventLogger(e.Item).Error("rename: %s", err)
getEventLogger(e.Item).Error("rename", "err", err)
}
case provider.DeleteEvent:
if err := s.delete(ctx, e.Item); err != nil {
getEventLogger(e.Item).Error("delete: %s", err)
getEventLogger(e.Item).Error("delete", "err", err)
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/thumbnail/thumbnail.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"log/slog"
"net/http"
"path"
"strings"
"time"

Expand Down Expand Up @@ -204,14 +205,12 @@ func (s Service) Serve(w http.ResponseWriter, r *http.Request, item absto.Item)
return
}

baseName := name

defer provider.LogClose(reader, "thumbnail.Serve", item.Pathname)

w.Header().Add("Cache-Control", cacheDuration)
w.Header().Add("Content-Disposition", fmt.Sprintf("inline; filename=%s", baseName))
w.Header().Add("Content-Disposition", fmt.Sprintf("inline; filename=%s", path.Base(name)))

http.ServeContent(w, r, baseName, item.Date, reader)
http.ServeContent(w, r, name, item.Date, reader)
}

func (s Service) List(w http.ResponseWriter, r *http.Request, item absto.Item, items []absto.Item) {
Expand Down

0 comments on commit 3e45295

Please sign in to comment.