From 3808b299c2f0f5d910773ad76724abfec4672ef0 Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Fri, 29 Oct 2021 08:20:36 +0200 Subject: [PATCH] no error logging on unsuported files for thumbnailer --- changelog/unreleased/fix-thumbnail-logging.md | 7 ++++++ webdav/pkg/service/v0/service.go | 25 +++++++++++-------- 2 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 changelog/unreleased/fix-thumbnail-logging.md diff --git a/changelog/unreleased/fix-thumbnail-logging.md b/changelog/unreleased/fix-thumbnail-logging.md new file mode 100644 index 00000000000..eac57980262 --- /dev/null +++ b/changelog/unreleased/fix-thumbnail-logging.md @@ -0,0 +1,7 @@ +Bugfix: Fix error logging when there is no thumbnail for a file + +We've fixed the behavior of the logging when there is no thumbnail for a file +(because the filetype is not supported for thumbnail generation). +Previously the WebDAV service always issues an error log in this case. Now, we don't log this event any more. + +https://github.com/owncloud/ocis/pull/2702 diff --git a/webdav/pkg/service/v0/service.go b/webdav/pkg/service/v0/service.go index f67c39b8e18..962942e6e9f 100644 --- a/webdav/pkg/service/v0/service.go +++ b/webdav/pkg/service/v0/service.go @@ -45,9 +45,9 @@ func NewService(opts ...Option) Service { m.Use(options.Middleware...) svc := Webdav{ - config: options.Config, - log: options.Logger, - mux: m, + config: options.Config, + log: options.Logger, + mux: m, thumbnailsClient: thumbnails.NewThumbnailService("com.owncloud.api.thumbnails", grpc.DefaultClient), } @@ -62,9 +62,9 @@ func NewService(opts ...Option) Service { // Webdav defines implements the business logic for Service. type Webdav struct { - config *config.Config - log log.Logger - mux *chi.Mux + config *config.Config + log log.Logger + mux *chi.Mux thumbnailsClient thumbnails.ThumbnailService } @@ -96,16 +96,18 @@ func (g Webdav) Thumbnail(w http.ResponseWriter, r *http.Request) { }, }) if err != nil { - g.log.Error().Err(err).Msg("could not get thumbnail") e := merrors.Parse(err.Error()) switch e.Code { case http.StatusNotFound: + // StatusNotFound is expected for unsupported files renderError(w, r, errNotFound(notFoundMsg(tr.Filename))) + return case http.StatusBadRequest: renderError(w, r, errBadRequest(err.Error())) default: renderError(w, r, errInternalError(err.Error())) } + g.log.Error().Err(err).Msg("could not get thumbnail") return } @@ -139,16 +141,18 @@ func (g Webdav) PublicThumbnail(w http.ResponseWriter, r *http.Request) { }, }) if err != nil { - g.log.Error().Err(err).Msg("could not get thumbnail") e := merrors.Parse(err.Error()) switch e.Code { case http.StatusNotFound: + // StatusNotFound is expected for unsupported files renderError(w, r, errNotFound(notFoundMsg(tr.Filename))) + return case http.StatusBadRequest: renderError(w, r, errBadRequest(err.Error())) default: renderError(w, r, errInternalError(err.Error())) } + g.log.Error().Err(err).Msg("could not get thumbnail") return } @@ -185,14 +189,15 @@ func (g Webdav) PublicThumbnailHead(w http.ResponseWriter, r *http.Request) { e := merrors.Parse(err.Error()) switch e.Code { case http.StatusNotFound: + // StatusNotFound is expected for unsupported files renderError(w, r, errNotFound(notFoundMsg(tr.Filename))) + return case http.StatusBadRequest: - g.log.Error().Err(err).Msg("could not get thumbnail") renderError(w, r, errBadRequest(err.Error())) default: - g.log.Error().Err(err).Msg("could not get thumbnail") renderError(w, r, errInternalError(err.Error())) } + g.log.Error().Err(err).Msg("could not get thumbnail") return }