mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Fix: do hard-copy when editing file with soft links
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -21,4 +21,6 @@ const (
|
||||
UserCtx
|
||||
// ThumbSizeCtx 缩略图尺寸
|
||||
ThumbSizeCtx
|
||||
// OriginSourceNameCtx 原始原文件名
|
||||
OriginSourceNameCtx
|
||||
)
|
||||
|
||||
@@ -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 {
|
||||
// 更新文件尺寸
|
||||
|
||||
54
pkg/filesystem/oss/handller.go
Normal file
54
pkg/filesystem/oss/handller.go
Normal 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("未实现")
|
||||
}
|
||||
Reference in New Issue
Block a user