no error logging on unsuported files for thumbnailer

This commit is contained in:
Willy Kloucek
2021-10-29 08:20:36 +02:00
parent d8e2935b4c
commit 3808b299c2
2 changed files with 22 additions and 10 deletions

View File

@@ -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

View File

@@ -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
}