diff --git a/services/thumbnails/pkg/service/grpc/v0/service.go b/services/thumbnails/pkg/service/grpc/v0/service.go index 4420258ad..76f33d713 100644 --- a/services/thumbnails/pkg/service/grpc/v0/service.go +++ b/services/thumbnails/pkg/service/grpc/v0/service.go @@ -3,6 +3,7 @@ package svc import ( "context" "image" + "net/http" "net/url" "path" "strings" @@ -13,6 +14,7 @@ import ( provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" revactx "github.com/cs3org/reva/v2/pkg/ctx" "github.com/cs3org/reva/v2/pkg/storagespace" + "github.com/cs3org/reva/v2/pkg/utils" "github.com/golang-jwt/jwt/v4" "github.com/owncloud/ocis/v2/ocis-pkg/log" thumbnailsmsg "github.com/owncloud/ocis/v2/protogen/gen/ocis/messages/thumbnails/v0" @@ -282,6 +284,14 @@ func (g Thumbnail) stat(path, auth string) (*provider.StatResponse, error) { if rsp.Info.Type != provider.ResourceType_RESOURCE_TYPE_FILE { return nil, merrors.BadRequest(g.serviceID, "Unsupported file type") } + if utils.ReadPlainFromOpaque(rsp.GetInfo().GetOpaque(), "status") == "processing" { + return nil, &merrors.Error{ + Id: g.serviceID, + Code: http.StatusTooEarly, + Detail: "File Processing", + Status: http.StatusText(http.StatusTooEarly), + } + } if rsp.Info.GetChecksum().GetSum() == "" { g.logger.Error().Msg("resource info is missing checksum") return nil, merrors.NotFound(g.serviceID, "resource info is missing a checksum") diff --git a/services/webdav/pkg/service/v0/service.go b/services/webdav/pkg/service/v0/service.go index 1d51ad1ea..2557b619c 100644 --- a/services/webdav/pkg/service/v0/service.go +++ b/services/webdav/pkg/service/v0/service.go @@ -245,6 +245,10 @@ func (g Webdav) SpacesThumbnail(w http.ResponseWriter, r *http.Request) { // StatusNotFound is expected for unsupported files renderError(w, r, errNotFound(notFoundMsg(tr.Filename))) return + case http.StatusTooEarly: + // StatusTooEarly if file is processing + renderError(w, r, errTooEarly(err.Error())) + return case http.StatusBadRequest: renderError(w, r, errBadRequest(err.Error())) default: @@ -508,6 +512,10 @@ func errNotFound(msg string) *errResponse { return newErrResponse(http.StatusNotFound, msg) } +func errTooEarly(msg string) *errResponse { + return newErrResponse(http.StatusTooEarly, msg) +} + func renderError(w http.ResponseWriter, r *http.Request, err *errResponse) { render.Status(r, err.HTTPStatusCode) render.XML(w, r, err)