Fix: do hard-copy when editing file with soft links

This commit is contained in:
HFO4
2020-01-16 10:11:16 +08:00
parent 098aa0a0c0
commit 0e62665d7f
6 changed files with 88 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/HFO4/cloudreve/pkg/auth"
"github.com/HFO4/cloudreve/pkg/conf"
"github.com/HFO4/cloudreve/pkg/filesystem/local"
"github.com/HFO4/cloudreve/pkg/filesystem/oss"
"github.com/HFO4/cloudreve/pkg/filesystem/qiniu"
"github.com/HFO4/cloudreve/pkg/filesystem/remote"
"github.com/HFO4/cloudreve/pkg/filesystem/response"
@@ -167,6 +168,11 @@ func (fs *FileSystem) dispatchHandler() error {
Policy: currentPolicy,
}
return nil
case "oss":
fs.Handler = oss.Handler{
Policy: currentPolicy,
}
return nil
default:
return ErrUnknownPolicyType
}

View File

@@ -21,4 +21,6 @@ const (
UserCtx
// ThumbSizeCtx 缩略图尺寸
ThumbSizeCtx
// OriginSourceNameCtx 原始原文件名
OriginSourceNameCtx
)

View File

@@ -177,6 +177,16 @@ func HookGiveBackCapacity(ctx context.Context, fs *FileSystem) error {
return nil
}
// HookUpdateSourceName 更新文件SourceName
// TODO测试
func HookUpdateSourceName(ctx context.Context, fs *FileSystem) error {
originFile, ok := ctx.Value(fsctx.FileModelCtx).(model.File)
if !ok {
return ErrObjectNotExist
}
return originFile.UpdateSourceName(originFile.SourceName)
}
// GenericAfterUpdate 文件内容更新后
func GenericAfterUpdate(ctx context.Context, fs *FileSystem) error {
// 更新文件尺寸

View File

@@ -0,0 +1,54 @@
package oss
import (
"context"
"errors"
model "github.com/HFO4/cloudreve/models"
"github.com/HFO4/cloudreve/pkg/filesystem/response"
"github.com/HFO4/cloudreve/pkg/serializer"
"io"
"net/url"
)
// Handler 阿里云OSS策略适配器
type Handler struct {
Policy *model.Policy
}
// Get 获取文件
func (handler Handler) Get(ctx context.Context, path string) (response.RSCloser, error) {
return nil, errors.New("未实现")
}
// Put 将文件流保存到指定目录
func (handler Handler) Put(ctx context.Context, file io.ReadCloser, dst string, size uint64) error {
return errors.New("未实现")
}
// Delete 删除一个或多个文件,
// 返回未删除的文件,及遇到的最后一个错误
func (handler Handler) Delete(ctx context.Context, files []string) ([]string, error) {
return []string{}, errors.New("未实现")
}
// Thumb 获取文件缩略图
func (handler Handler) Thumb(ctx context.Context, path string) (*response.ContentResponse, error) {
return nil, errors.New("未实现")
}
// Source 获取外链URL
func (handler Handler) Source(
ctx context.Context,
path string,
baseURL url.URL,
ttl int64,
isDownload bool,
speed int,
) (string, error) {
return "", errors.New("未实现")
}
// Token 获取上传策略和认证Token
func (handler Handler) Token(ctx context.Context, TTL int64, key string) (serializer.UploadCredential, error) {
return serializer.UploadCredential{}, errors.New("未实现")
}