Merge pull request #3669 from owncloud/thumbnails-fix
reduce hacky reference handling in thumbnailer
This commit is contained in:
@@ -3,3 +3,4 @@ Change: Use new space ID util functions
|
|||||||
Changed code to use the new space ID util functions so that everything works with the new spaces ID format.
|
Changed code to use the new space ID util functions so that everything works with the new spaces ID format.
|
||||||
|
|
||||||
https://github.com/owncloud/ocis/pull/3648
|
https://github.com/owncloud/ocis/pull/3648
|
||||||
|
https://github.com/owncloud/ocis/pull/3669
|
||||||
|
|||||||
@@ -256,20 +256,16 @@ func (g Thumbnail) handleWebdavSource(ctx context.Context,
|
|||||||
func (g Thumbnail) stat(path, auth string) (*provider.StatResponse, error) {
|
func (g Thumbnail) stat(path, auth string) (*provider.StatResponse, error) {
|
||||||
ctx := metadata.AppendToOutgoingContext(context.Background(), revactx.TokenHeader, auth)
|
ctx := metadata.AppendToOutgoingContext(context.Background(), revactx.TokenHeader, auth)
|
||||||
|
|
||||||
var ref *provider.Reference
|
ref, err := storagespace.ParseReference(path)
|
||||||
if strings.Contains(path, "!") {
|
if err != nil {
|
||||||
parsed, err := storagespace.ParseReference(path)
|
// If the path is not a spaces reference try to handle it like a plain
|
||||||
if err != nil {
|
// path reference.
|
||||||
return nil, err
|
ref = provider.Reference{
|
||||||
}
|
|
||||||
ref = &parsed
|
|
||||||
} else {
|
|
||||||
ref = &provider.Reference{
|
|
||||||
Path: path,
|
Path: path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
req := &provider.StatRequest{Ref: ref}
|
req := &provider.StatRequest{Ref: &ref}
|
||||||
rsp, err := g.cs3Client.Stat(ctx, req)
|
rsp, err := g.cs3Client.Stat(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.logger.Error().Err(err).Str("path", path).Msg("could not stat file")
|
g.logger.Error().Err(err).Str("path", path).Msg("could not stat file")
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
|
|
||||||
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
||||||
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
|
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
|
||||||
@@ -44,20 +43,16 @@ func (s CS3) Get(ctx context.Context, path string) (io.ReadCloser, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil, errors.New("cs3source: authorization missing")
|
return nil, errors.New("cs3source: authorization missing")
|
||||||
}
|
}
|
||||||
var ref *provider.Reference
|
ref, err := storagespace.ParseReference(path)
|
||||||
if strings.Contains(path, "!") {
|
if err != nil {
|
||||||
parsed, err := storagespace.ParseReference(path)
|
// If the path is not a spaces reference try to handle it like a plain
|
||||||
if err != nil {
|
// path reference.
|
||||||
return nil, err
|
ref = provider.Reference{
|
||||||
}
|
|
||||||
ref = &parsed
|
|
||||||
} else {
|
|
||||||
ref = &provider.Reference{
|
|
||||||
Path: path,
|
Path: path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx = metadata.AppendToOutgoingContext(context.Background(), revactx.TokenHeader, auth)
|
ctx = metadata.AppendToOutgoingContext(context.Background(), revactx.TokenHeader, auth)
|
||||||
rsp, err := s.client.InitiateFileDownload(ctx, &provider.InitiateFileDownloadRequest{Ref: ref})
|
rsp, err := s.client.InitiateFileDownload(ctx, &provider.InitiateFileDownloadRequest{Ref: &ref})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ func (g Webdav) SpacesThumbnail(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
t := r.Header.Get(TokenHeader)
|
t := r.Header.Get(TokenHeader)
|
||||||
|
|
||||||
fullPath := tr.Identifier + "!" + tr.Filepath
|
fullPath := tr.Identifier + tr.Filepath
|
||||||
rsp, err := g.thumbnailsClient.GetThumbnail(r.Context(), &thumbnailssvc.GetThumbnailRequest{
|
rsp, err := g.thumbnailsClient.GetThumbnail(r.Context(), &thumbnailssvc.GetThumbnailRequest{
|
||||||
Filepath: strings.TrimLeft(tr.Filepath, "/"),
|
Filepath: strings.TrimLeft(tr.Filepath, "/"),
|
||||||
ThumbnailType: extensionToThumbnailType(strings.TrimLeft(tr.Extension, ".")),
|
ThumbnailType: extensionToThumbnailType(strings.TrimLeft(tr.Extension, ".")),
|
||||||
|
|||||||
Reference in New Issue
Block a user