mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-01 01:41:13 -06:00
return 425 on thumbnails when file is processing
Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user