feat(thumb): generate thumb for OneDrive files

This commit is contained in:
Aaron Liu
2023-04-07 19:27:31 +08:00
parent 62b73b577b
commit e115497dfe
4 changed files with 12 additions and 6 deletions

View File

@@ -147,11 +147,13 @@ func (handler Driver) Thumb(ctx context.Context, file *model.File) (*response.Co
res, err := handler.Client.GetThumbURL(ctx, file.SourceName, thumbSize[0], thumbSize[1])
if err != nil {
// 如果出现异常就清空文件的pic_info
if file, ok := ctx.Value(fsctx.FileModelCtx).(model.File); ok {
file.UpdatePicInfo("")
var apiErr *RespError
if errors.As(err, &apiErr); err == ErrThumbSizeNotFound || (apiErr != nil && apiErr.APIError.Code == notFoundError) {
// OneDrive cannot generate thumbnail for this file
return nil, driver.ErrorThumbNotSupported
}
}
return &response.ContentResponse{
Redirect: true,
URL: res,