Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no error logging on unsupported files for thumbnailer #2702

Merged
merged 1 commit into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/fix-thumbnail-logging.md
Original file line number Diff line number Diff line change
@@ -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
25 changes: 15 additions & 10 deletions webdav/pkg/service/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

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

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down