i18n: logs in conf/crontab/email/fs.driver

pull/1491/head
HFO4 2 years ago
parent 9bb4a5263c
commit 196729bae8

@ -85,13 +85,13 @@ func Init(path string) {
}, defaultConf) }, defaultConf)
f, err := util.CreatNestedFile(path) f, err := util.CreatNestedFile(path)
if err != nil { if err != nil {
util.Log().Panic("无法创建配置文件, %s", err) util.Log().Panic("Failed to create config file: %s", err)
} }
// 写入配置文件 // 写入配置文件
_, err = f.WriteString(confContent) _, err = f.WriteString(confContent)
if err != nil { if err != nil {
util.Log().Panic("无法写入配置文件, %s", err) util.Log().Panic("Failed to write config file: %s", err)
} }
f.Close() f.Close()
@ -99,7 +99,7 @@ func Init(path string) {
cfg, err = ini.Load(path) cfg, err = ini.Load(path)
if err != nil { if err != nil {
util.Log().Panic("无法解析配置文件 '%s': %s", path, err) util.Log().Panic("Failed to parse config file %q: %s", path, err)
} }
sections := map[string]interface{}{ sections := map[string]interface{}{
@ -114,7 +114,7 @@ func Init(path string) {
for sectionName, sectionStruct := range sections { for sectionName, sectionStruct := range sections {
err = mapSection(sectionName, sectionStruct) err = mapSection(sectionName, sectionStruct)
if err != nil { if err != nil {
util.Log().Panic("配置文件 %s 分区解析失败: %s", sectionName, err) util.Log().Panic("Failed to parse config section %q: %s", sectionName, err)
} }
} }

@ -22,7 +22,7 @@ func garbageCollect() {
collectCache(store) collectCache(store)
} }
util.Log().Info("定时任务 [cron_garbage_collect] 执行完毕") util.Log().Info("Crontab job \"cron_garbage_collect\" complete.")
} }
func collectArchiveFile() { func collectArchiveFile() {
@ -36,23 +36,23 @@ func collectArchiveFile() {
if err == nil && !info.IsDir() && if err == nil && !info.IsDir() &&
strings.HasPrefix(filepath.Base(path), "archive_") && strings.HasPrefix(filepath.Base(path), "archive_") &&
time.Now().Sub(info.ModTime()).Seconds() > float64(expires) { time.Now().Sub(info.ModTime()).Seconds() > float64(expires) {
util.Log().Debug("删除过期打包下载临时文件 [%s]", path) util.Log().Debug("Delete expired batch download temp file %q.", path)
// 删除符合条件的文件 // 删除符合条件的文件
if err := os.Remove(path); err != nil { if err := os.Remove(path); err != nil {
util.Log().Debug("临时文件 [%s] 删除失败 , %s", path, err) util.Log().Debug("Failed to delete temp file %q: %s", path, err)
} }
} }
return nil return nil
}) })
if err != nil { if err != nil {
util.Log().Debug("[定时任务] 无法列取临时打包目录") util.Log().Debug("Crontab job cannot list temp batch download folder: %s", err)
} }
} }
func collectCache(store *cache.MemoStore) { func collectCache(store *cache.MemoStore) {
util.Log().Debug("清理内存缓存") util.Log().Debug("Cleanup memory cache.")
store.GarbageCollect() store.GarbageCollect()
} }
@ -78,22 +78,22 @@ func uploadSessionCollect() {
for uid, filesIDs := range userToFiles { for uid, filesIDs := range userToFiles {
user, err := model.GetUserByID(uid) user, err := model.GetUserByID(uid)
if err != nil { if err != nil {
util.Log().Warning("上传会话所属用户不存在, %s", err) util.Log().Warning("Owner of the upload session cannot be found: %s", err)
continue continue
} }
fs, err := filesystem.NewFileSystem(&user) fs, err := filesystem.NewFileSystem(&user)
if err != nil { if err != nil {
util.Log().Warning("无法初始化文件系统, %s", err) util.Log().Warning("Failed to initialize filesystem: %s", err)
continue continue
} }
if err = fs.Delete(context.Background(), []uint{}, filesIDs, false); err != nil { if err = fs.Delete(context.Background(), []uint{}, filesIDs, false); err != nil {
util.Log().Warning("无法删除上传会话, %s", err) util.Log().Warning("Failed to delete upload session: %s", err)
} }
fs.Recycle() fs.Recycle()
} }
util.Log().Info("定时任务 [cron_recycle_upload_session] 执行完毕") util.Log().Info("Crontab job \"cron_recycle_upload_session\" complete.")
} }

@ -19,7 +19,7 @@ func Reload() {
// Init 初始化定时任务 // Init 初始化定时任务
func Init() { func Init() {
util.Log().Info("初始化定时任务...") util.Log().Info("Initialize crontab jobs...")
// 读取cron日程设置 // 读取cron日程设置
options := model.GetSettingByNames( options := model.GetSettingByNames(
"cron_garbage_collect", "cron_garbage_collect",
@ -34,12 +34,12 @@ func Init() {
case "cron_recycle_upload_session": case "cron_recycle_upload_session":
handler = uploadSessionCollect handler = uploadSessionCollect
default: default:
util.Log().Warning("未知定时任务类型 [%s],跳过", k) util.Log().Warning("Unknown crontab job type %q, skipping...", k)
continue continue
} }
if _, err := Cron.AddFunc(v, handler); err != nil { if _, err := Cron.AddFunc(v, handler); err != nil {
util.Log().Warning("无法启动定时任务 [%s] , %s", k, err) util.Log().Warning("Failed to start crontab job %q: %s", k, err)
} }
} }

@ -15,7 +15,7 @@ var Lock sync.RWMutex
// Init 初始化 // Init 初始化
func Init() { func Init() {
util.Log().Debug("邮件队列初始化") util.Log().Debug("Initializing email sending queue...")
Lock.Lock() Lock.Lock()
defer Lock.Unlock() defer Lock.Unlock()

@ -15,9 +15,9 @@ type Driver interface {
var ( var (
// ErrChanNotOpen 邮件队列未开启 // ErrChanNotOpen 邮件队列未开启
ErrChanNotOpen = errors.New("邮件队列未开启") ErrChanNotOpen = errors.New("email queue is not started")
// ErrNoActiveDriver 无可用邮件发送服务 // ErrNoActiveDriver 无可用邮件发送服务
ErrNoActiveDriver = errors.New("无可用邮件发送服务") ErrNoActiveDriver = errors.New("no avaliable email provider")
) )
// Send 发送邮件 // Send 发送邮件

@ -68,7 +68,7 @@ func (client *SMTP) Init() {
defer func() { defer func() {
if err := recover(); err != nil { if err := recover(); err != nil {
client.chOpen = false client.chOpen = false
util.Log().Error("邮件发送队列出现异常, %s ,10 秒后重置", err) util.Log().Error("Exception while sending email: %s, queue will be reset in 10 seconds.", err)
time.Sleep(time.Duration(10) * time.Second) time.Sleep(time.Duration(10) * time.Second)
client.Init() client.Init()
} }
@ -91,7 +91,7 @@ func (client *SMTP) Init() {
select { select {
case m, ok := <-client.ch: case m, ok := <-client.ch:
if !ok { if !ok {
util.Log().Debug("邮件队列关闭") util.Log().Debug("Email queue closing...")
client.chOpen = false client.chOpen = false
return return
} }
@ -102,15 +102,15 @@ func (client *SMTP) Init() {
open = true open = true
} }
if err := mail.Send(s, m); err != nil { if err := mail.Send(s, m); err != nil {
util.Log().Warning("邮件发送失败, %s", err) util.Log().Warning("Failed to send email: %s", err)
} else { } else {
util.Log().Debug("邮件已发送") util.Log().Debug("Email sent.")
} }
// 长时间没有新邮件则关闭SMTP连接 // 长时间没有新邮件则关闭SMTP连接
case <-time.After(time.Duration(client.Config.Keepalive) * time.Second): case <-time.After(time.Duration(client.Config.Keepalive) * time.Second):
if open { if open {
if err := s.Close(); err != nil { if err := s.Close(); err != nil {
util.Log().Warning("无法关闭 SMTP 连接 %s", err) util.Log().Warning("Failed to close SMTP connection: %s", err)
} }
open = false open = false
} }

@ -218,7 +218,7 @@ func (handler Driver) Delete(ctx context.Context, files []string) ([]string, err
return failed, nil return failed, nil
} }
return failed, errors.New("删除失败") return failed, errors.New("delete failed")
} }
// Thumb 获取文件缩略图 // Thumb 获取文件缩略图

@ -43,7 +43,7 @@ func (handler Driver) List(ctx context.Context, path string, recursive bool) ([]
} }
if err != nil { if err != nil {
util.Log().Warning("无法遍历目录 %s, %s", path, err) util.Log().Warning("Failed to walk folder %q: %s", path, err)
return filepath.SkipDir return filepath.SkipDir
} }
@ -78,7 +78,7 @@ func (handler Driver) Get(ctx context.Context, path string) (response.RSCloser,
// 打开文件 // 打开文件
file, err := os.Open(util.RelativePath(path)) file, err := os.Open(util.RelativePath(path))
if err != nil { if err != nil {
util.Log().Debug("无法打开文件:%s", err) util.Log().Debug("Failed to open file: %s", err)
return nil, err return nil, err
} }
@ -94,8 +94,8 @@ func (handler Driver) Put(ctx context.Context, file fsctx.FileHeader) error {
// 如果非 Overwrite则检查是否有重名冲突 // 如果非 Overwrite则检查是否有重名冲突
if fileInfo.Mode&fsctx.Overwrite != fsctx.Overwrite { if fileInfo.Mode&fsctx.Overwrite != fsctx.Overwrite {
if util.Exists(dst) { if util.Exists(dst) {
util.Log().Warning("物理同名文件已存在或不可用: %s", dst) util.Log().Warning("File with the same name existed or unavailable: %s", dst)
return errors.New("物理同名文件已存在或不可用") return errors.New("file with the same name existed or unavailable")
} }
} }
@ -104,7 +104,7 @@ func (handler Driver) Put(ctx context.Context, file fsctx.FileHeader) error {
if !util.Exists(basePath) { if !util.Exists(basePath) {
err := os.MkdirAll(basePath, Perm) err := os.MkdirAll(basePath, Perm)
if err != nil { if err != nil {
util.Log().Warning("无法创建目录,%s", err) util.Log().Warning("Failed to create directory: %s", err)
return err return err
} }
} }
@ -123,7 +123,7 @@ func (handler Driver) Put(ctx context.Context, file fsctx.FileHeader) error {
out, err = os.OpenFile(dst, openMode, Perm) out, err = os.OpenFile(dst, openMode, Perm)
if err != nil { if err != nil {
util.Log().Warning("无法打开或创建文件,%s", err) util.Log().Warning("Failed to open or create file: %s", err)
return err return err
} }
defer out.Close() defer out.Close()
@ -131,22 +131,22 @@ func (handler Driver) Put(ctx context.Context, file fsctx.FileHeader) error {
if fileInfo.Mode&fsctx.Append == fsctx.Append { if fileInfo.Mode&fsctx.Append == fsctx.Append {
stat, err := out.Stat() stat, err := out.Stat()
if err != nil { if err != nil {
util.Log().Warning("无法读取文件信息,%s", err) util.Log().Warning("Failed to read file info: %s", err)
return err return err
} }
if uint64(stat.Size()) < fileInfo.AppendStart { if uint64(stat.Size()) < fileInfo.AppendStart {
return errors.New("未上传完成的文件分片与预期大小不一致") return errors.New("size of unfinished uploaded chunks is not as expected")
} else if uint64(stat.Size()) > fileInfo.AppendStart { } else if uint64(stat.Size()) > fileInfo.AppendStart {
out.Close() out.Close()
if err := handler.Truncate(ctx, dst, fileInfo.AppendStart); err != nil { if err := handler.Truncate(ctx, dst, fileInfo.AppendStart); err != nil {
return fmt.Errorf("覆盖分片时发生错误: %w", err) return fmt.Errorf("failed to overwrite chunk: %w", err)
} }
out, err = os.OpenFile(dst, openMode, Perm) out, err = os.OpenFile(dst, openMode, Perm)
defer out.Close() defer out.Close()
if err != nil { if err != nil {
util.Log().Warning("无法打开或创建文件,%s", err) util.Log().Warning("Failed to create or open file: %s", err)
return err return err
} }
} }
@ -158,10 +158,10 @@ func (handler Driver) Put(ctx context.Context, file fsctx.FileHeader) error {
} }
func (handler Driver) Truncate(ctx context.Context, src string, size uint64) error { func (handler Driver) Truncate(ctx context.Context, src string, size uint64) error {
util.Log().Warning("截断文件 [%s] 至 [%d]", src, size) util.Log().Warning("Truncate file %q to [%d].", src, size)
out, err := os.OpenFile(src, os.O_WRONLY, Perm) out, err := os.OpenFile(src, os.O_WRONLY, Perm)
if err != nil { if err != nil {
util.Log().Warning("无法打开文件,%s", err) util.Log().Warning("Failed to open file: %s", err)
return err return err
} }
@ -180,7 +180,7 @@ func (handler Driver) Delete(ctx context.Context, files []string) ([]string, err
if util.Exists(filePath) { if util.Exists(filePath) {
err := os.Remove(filePath) err := os.Remove(filePath)
if err != nil { if err != nil {
util.Log().Warning("无法删除文件,%s", err) util.Log().Warning("Failed to delete file: %s", err)
retErr = err retErr = err
deleteFailed = append(deleteFailed, value) deleteFailed = append(deleteFailed, value)
} }
@ -217,7 +217,7 @@ func (handler Driver) Source(
) (string, error) { ) (string, error) {
file, ok := ctx.Value(fsctx.FileModelCtx).(model.File) file, ok := ctx.Value(fsctx.FileModelCtx).(model.File)
if !ok { if !ok {
return "", errors.New("无法获取文件记录上下文") return "", errors.New("failed to read file model context")
} }
// 是否启用了CDN // 是否启用了CDN
@ -238,7 +238,7 @@ func (handler Driver) Source(
downloadSessionID := util.RandStringRunes(16) downloadSessionID := util.RandStringRunes(16)
err = cache.Set("download_"+downloadSessionID, file, int(ttl)) err = cache.Set("download_"+downloadSessionID, file, int(ttl))
if err != nil { if err != nil {
return "", serializer.NewError(serializer.CodeCacheOperation, "无法创建下载会话", err) return "", serializer.NewError(serializer.CodeCacheOperation, "Failed to create download session", err)
} }
// 签名生成文件记录 // 签名生成文件记录
@ -257,7 +257,7 @@ func (handler Driver) Source(
} }
if err != nil { if err != nil {
return "", serializer.NewError(serializer.CodeEncryptError, "无法对URL进行签名", err) return "", serializer.NewError(serializer.CodeEncryptError, "Failed to sign url", err)
} }
finalURL := baseURL.ResolveReference(signedURI).String() finalURL := baseURL.ResolveReference(signedURI).String()

@ -95,7 +95,7 @@ func (client *Client) ListChildren(ctx context.Context, path string) ([]FileInfo
} }
if retried < ListRetry { if retried < ListRetry {
retried++ retried++
util.Log().Debug("路径[%s]列取请求失败[%s]5秒钟后重试", path, err) util.Log().Debug("Failed to list path %q: %s, will retry in 5 seconds.", path, err)
time.Sleep(time.Duration(5) * time.Second) time.Sleep(time.Duration(5) * time.Second)
return client.ListChildren(context.WithValue(ctx, fsctx.RetryCtx, retried), path) return client.ListChildren(context.WithValue(ctx, fsctx.RetryCtx, retried), path)
} }
@ -445,7 +445,7 @@ func (client *Client) GetThumbURL(ctx context.Context, dst string, w, h uint) (s
} }
} }
return "", errors.New("无法生成缩略图") return "", errors.New("failed to generate thumb")
} }
// MonitorUpload 监控客户端分片上传进度 // MonitorUpload 监控客户端分片上传进度
@ -460,39 +460,39 @@ func (client *Client) MonitorUpload(uploadURL, callbackKey, path string, size ui
for { for {
select { select {
case <-callbackChan: case <-callbackChan:
util.Log().Debug("客户端完成回调") util.Log().Debug("Client finished OneDrive callback.")
return return
case <-time.After(time.Duration(ttl) * time.Second): case <-time.After(time.Duration(ttl) * time.Second):
// 上传会话到期,仍未完成上传,创建占位符 // 上传会话到期,仍未完成上传,创建占位符
client.DeleteUploadSession(context.Background(), uploadURL) client.DeleteUploadSession(context.Background(), uploadURL)
_, err := client.SimpleUpload(context.Background(), path, strings.NewReader(""), 0, WithConflictBehavior("replace")) _, err := client.SimpleUpload(context.Background(), path, strings.NewReader(""), 0, WithConflictBehavior("replace"))
if err != nil { if err != nil {
util.Log().Debug("无法创建占位文件,%s", err) util.Log().Debug("Failed to create placeholder file: %s", err)
} }
return return
case <-time.After(time.Duration(timeout) * time.Second): case <-time.After(time.Duration(timeout) * time.Second):
util.Log().Debug("检查上传情况") util.Log().Debug("Checking OneDrive upload status.")
status, err := client.GetUploadSessionStatus(context.Background(), uploadURL) status, err := client.GetUploadSessionStatus(context.Background(), uploadURL)
if err != nil { if err != nil {
if resErr, ok := err.(*RespError); ok { if resErr, ok := err.(*RespError); ok {
if resErr.APIError.Code == "itemNotFound" { if resErr.APIError.Code == "itemNotFound" {
util.Log().Debug("上传会话已完成,稍后检查回调") util.Log().Debug("Upload completed, will check upload callback later.")
select { select {
case <-time.After(time.Duration(interval) * time.Second): case <-time.After(time.Duration(interval) * time.Second):
util.Log().Warning("未发送回调,删除文件") util.Log().Warning("No callback is made, file will be deleted.")
cache.Deletes([]string{callbackKey}, "callback_") cache.Deletes([]string{callbackKey}, "callback_")
_, err = client.Delete(context.Background(), []string{path}) _, err = client.Delete(context.Background(), []string{path})
if err != nil { if err != nil {
util.Log().Warning("无法删除未回调的文件,%s", err) util.Log().Warning("Failed to delete file without callback: %s", err)
} }
case <-callbackChan: case <-callbackChan:
util.Log().Debug("客户端完成回调") util.Log().Debug("Client finished callback.")
} }
return return
} }
} }
util.Log().Debug("无法获取上传会话状态,继续下一轮,%s", err.Error()) util.Log().Debug("Failed to get upload session status: %s, continue next iteration.", err.Error())
continue continue
} }
@ -509,7 +509,7 @@ func (client *Client) MonitorUpload(uploadURL, callbackKey, path string, size ui
} }
uploadFullSize, _ := strconv.ParseUint(sizeRange[1], 10, 64) uploadFullSize, _ := strconv.ParseUint(sizeRange[1], 10, 64)
if (sizeRange[0] == "0" && sizeRange[1] == "") || uploadFullSize+1 != size { if (sizeRange[0] == "0" && sizeRange[1] == "") || uploadFullSize+1 != size {
util.Log().Debug("未开始上传或文件大小不一致,取消上传会话") util.Log().Debug("Upload has not started, or uploaded file size not match, canceling upload session...")
// 取消上传会话实测OneDrive取消上传会话后客户端还是可以上传 // 取消上传会话实测OneDrive取消上传会话后客户端还是可以上传
// 所以上传一个空文件占位,阻止客户端上传 // 所以上传一个空文件占位,阻止客户端上传
client.DeleteUploadSession(context.Background(), uploadURL) client.DeleteUploadSession(context.Background(), uploadURL)
@ -577,7 +577,7 @@ func (client *Client) request(ctx context.Context, method string, url string, bo
if res.Response.StatusCode < 200 || res.Response.StatusCode >= 300 { if res.Response.StatusCode < 200 || res.Response.StatusCode >= 300 {
decodeErr = json.Unmarshal([]byte(respBody), &errResp) decodeErr = json.Unmarshal([]byte(respBody), &errResp)
if decodeErr != nil { if decodeErr != nil {
util.Log().Debug("Onedrive返回未知响应[%s]", respBody) util.Log().Debug("Onedrive returns unknown response: %s", respBody)
return "", sysError(decodeErr) return "", sysError(decodeErr)
} }
return "", &errResp return "", &errResp

@ -10,13 +10,13 @@ import (
var ( var (
// ErrAuthEndpoint 无法解析授权端点地址 // ErrAuthEndpoint 无法解析授权端点地址
ErrAuthEndpoint = errors.New("无法解析授权端点地址") ErrAuthEndpoint = errors.New("failed to parse endpoint url")
// ErrInvalidRefreshToken 上传策略无有效的RefreshToken // ErrInvalidRefreshToken 上传策略无有效的RefreshToken
ErrInvalidRefreshToken = errors.New("上传策略无有效的RefreshToken") ErrInvalidRefreshToken = errors.New("no valid refresh token in this policy")
// ErrDeleteFile 无法删除文件 // ErrDeleteFile 无法删除文件
ErrDeleteFile = errors.New("无法删除文件") ErrDeleteFile = errors.New("cannot delete file")
// ErrClientCanceled 客户端取消操作 // ErrClientCanceled 客户端取消操作
ErrClientCanceled = errors.New("客户端取消操作") ErrClientCanceled = errors.New("client canceled")
) )
// Client OneDrive客户端 // Client OneDrive客户端

@ -143,7 +143,7 @@ func (handler Driver) Thumb(ctx context.Context, path string) (*response.Content
ok = false ok = false
) )
if thumbSize, ok = ctx.Value(fsctx.ThumbSizeCtx).([2]uint); !ok { if thumbSize, ok = ctx.Value(fsctx.ThumbSizeCtx).([2]uint); !ok {
return nil, errors.New("无法获取缩略图尺寸设置") return nil, errors.New("failed to get thumbnail size")
} }
res, err := handler.Client.GetThumbURL(ctx, path, thumbSize[0], thumbSize[1]) res, err := handler.Client.GetThumbURL(ctx, path, thumbSize[0], thumbSize[1])

@ -152,7 +152,7 @@ func (client *Client) UpdateCredential(ctx context.Context, isSlave bool) error
// 获取新的凭证 // 获取新的凭证
if client.Credential == nil || client.Credential.RefreshToken == "" { if client.Credential == nil || client.Credential.RefreshToken == "" {
// 无有效的RefreshToken // 无有效的RefreshToken
util.Log().Error("上传策略[%s]凭证刷新失败请重新授权OneDrive账号", client.Policy.Name) util.Log().Error("Failed to refresh credential for policy %q, please login your Microsoft account again.", client.Policy.Name)
return ErrInvalidRefreshToken return ErrInvalidRefreshToken
} }

@ -38,7 +38,7 @@ func GetPublicKey(r *http.Request) ([]byte, error) {
// 确保这个 public key 是由 OSS 颁发的 // 确保这个 public key 是由 OSS 颁发的
if !strings.HasPrefix(string(pubURL), "http://gosspublic.alicdn.com/") && if !strings.HasPrefix(string(pubURL), "http://gosspublic.alicdn.com/") &&
!strings.HasPrefix(string(pubURL), "https://gosspublic.alicdn.com/") { !strings.HasPrefix(string(pubURL), "https://gosspublic.alicdn.com/") {
return pubKey, errors.New("公钥URL无效") return pubKey, errors.New("public key url invalid")
} }
// 获取公钥 // 获取公钥

@ -91,7 +91,7 @@ func (handler *Driver) CORS() error {
// InitOSSClient 初始化OSS鉴权客户端 // InitOSSClient 初始化OSS鉴权客户端
func (handler *Driver) InitOSSClient(forceUsePublicEndpoint bool) error { func (handler *Driver) InitOSSClient(forceUsePublicEndpoint bool) error {
if handler.Policy == nil { if handler.Policy == nil {
return errors.New("存储策略为空") return errors.New("empty policy")
} }
// 决定是否使用内网 Endpoint // 决定是否使用内网 Endpoint
@ -286,7 +286,7 @@ func (handler *Driver) Delete(ctx context.Context, files []string) ([]string, er
// 统计未删除的文件 // 统计未删除的文件
failed := util.SliceDifference(files, delRes.DeletedObjects) failed := util.SliceDifference(files, delRes.DeletedObjects)
if len(failed) > 0 { if len(failed) > 0 {
return failed, errors.New("删除失败") return failed, errors.New("failed to delete")
} }
return []string{}, nil return []string{}, nil
@ -304,7 +304,7 @@ func (handler *Driver) Thumb(ctx context.Context, path string) (*response.Conten
ok = false ok = false
) )
if thumbSize, ok = ctx.Value(fsctx.ThumbSizeCtx).([2]uint); !ok { if thumbSize, ok = ctx.Value(fsctx.ThumbSizeCtx).([2]uint); !ok {
return nil, errors.New("无法获取缩略图尺寸设置") return nil, errors.New("failed to get thumbnail size")
} }
thumbParam := fmt.Sprintf("image/resize,m_lfit,h_%d,w_%d", thumbSize[1], thumbSize[0]) thumbParam := fmt.Sprintf("image/resize,m_lfit,h_%d,w_%d", thumbSize[1], thumbSize[0])

@ -197,7 +197,7 @@ func (handler *Driver) Delete(ctx context.Context, files []string) ([]string, er
return failedResp.Files, errors.New(reqResp.Error) return failedResp.Files, errors.New(reqResp.Error)
} }
} }
return files, errors.New("未知的返回结果格式") return files, errors.New("unknown format of returned response")
} }
return []string{}, nil return []string{}, nil
@ -265,7 +265,7 @@ func (handler *Driver) Source(
) )
if err != nil { if err != nil {
return "", serializer.NewError(serializer.CodeEncryptError, "无法对URL进行签名", err) return "", serializer.NewError(serializer.CodeEncryptError, "Failed to sign URL", err)
} }
finalURL := serverURL.ResolveReference(signedURI).String() finalURL := serverURL.ResolveReference(signedURI).String()

@ -62,7 +62,7 @@ func NewDriver(policy *model.Policy) (*Driver, error) {
// InitS3Client 初始化S3会话 // InitS3Client 初始化S3会话
func (handler *Driver) InitS3Client() error { func (handler *Driver) InitS3Client() error {
if handler.Policy == nil { if handler.Policy == nil {
return errors.New("存储策略为空") return errors.New("empty policy")
} }
if handler.svc == nil { if handler.svc == nil {

@ -226,7 +226,7 @@ func (handler Driver) Thumb(ctx context.Context, path string) (*response.Content
ok = false ok = false
) )
if thumbSize, ok = ctx.Value(fsctx.ThumbSizeCtx).([2]uint); !ok { if thumbSize, ok = ctx.Value(fsctx.ThumbSizeCtx).([2]uint); !ok {
return nil, errors.New("无法获取缩略图尺寸设置") return nil, errors.New("failed to get thumbnail size")
} }
thumbParam := fmt.Sprintf("!/fwfh/%dx%d", thumbSize[0], thumbSize[1]) thumbParam := fmt.Sprintf("!/fwfh/%dx%d", thumbSize[0], thumbSize[1])

Loading…
Cancel
Save