diff --git a/pkg/filesystem/archive.go b/pkg/filesystem/archive.go index 7e62590..78fc45f 100644 --- a/pkg/filesystem/archive.go +++ b/pkg/filesystem/archive.go @@ -107,7 +107,7 @@ func (fs *FileSystem) doCompress(ctx context.Context, file *model.File, folder * fs.Policy = file.GetPolicy() err := fs.DispatchHandler() if err != nil { - util.Log().Warning("无法压缩文件%s,%s", file.Name, err) + util.Log().Warning("Failed to compress file %q: %s", file.Name, err) return } @@ -117,7 +117,7 @@ func (fs *FileSystem) doCompress(ctx context.Context, file *model.File, folder * file.SourceName, ) if err != nil { - util.Log().Debug("Open%s,%s", file.Name, err) + util.Log().Debug("Failed to open %q: %s", file.Name, err) return } if closer, ok := fileToZip.(io.Closer); ok { @@ -176,7 +176,7 @@ func (fs *FileSystem) Decompress(ctx context.Context, src, dst, encoding string) // 结束时删除临时压缩文件 if tempZipFilePath != "" { if err := os.Remove(tempZipFilePath); err != nil { - util.Log().Warning("无法删除临时压缩文件 %s , %s", tempZipFilePath, err) + util.Log().Warning("Failed to delete temp archive file %q: %s", tempZipFilePath, err) } } }() @@ -197,7 +197,7 @@ func (fs *FileSystem) Decompress(ctx context.Context, src, dst, encoding string) zipFile, err := util.CreatNestedFile(tempZipFilePath) if err != nil { - util.Log().Warning("无法创建临时压缩文件 %s , %s", tempZipFilePath, err) + util.Log().Warning("Failed to create temp archive file %q: %s", tempZipFilePath, err) tempZipFilePath = "" return err } @@ -206,7 +206,7 @@ func (fs *FileSystem) Decompress(ctx context.Context, src, dst, encoding string) // 下载前先判断是否是可解压的格式 format, readStream, err := archiver.Identify(fs.FileTarget[0].SourceName, fileStream) if err != nil { - util.Log().Warning("无法识别文件格式 %s , %s", fs.FileTarget[0].SourceName, err) + util.Log().Warning("Failed to detect compressed format of file %q: %s", fs.FileTarget[0].SourceName, err) return err } @@ -228,7 +228,7 @@ func (fs *FileSystem) Decompress(ctx context.Context, src, dst, encoding string) if isZip { _, err = io.Copy(zipFile, readStream) if err != nil { - util.Log().Warning("无法写入临时压缩文件 %s , %s", tempZipFilePath, err) + util.Log().Warning("Failed to write temp archive file %q: %s", tempZipFilePath, err) return err } @@ -261,7 +261,7 @@ func (fs *FileSystem) Decompress(ctx context.Context, src, dst, encoding string) wg.Done() } if err := recover(); err != nil { - util.Log().Warning("上传压缩包内文件时出错") + util.Log().Warning("Error while uploading files inside of archive file.") fmt.Println(err) } }() @@ -274,7 +274,7 @@ func (fs *FileSystem) Decompress(ctx context.Context, src, dst, encoding string) }, true) fileStream.Close() if err != nil { - util.Log().Debug("无法上传压缩包内的文件%s , %s , 跳过", rawPath, err) + util.Log().Debug("Failed to upload file %q in archive file: %s, skipping...", rawPath, err) } } @@ -297,7 +297,7 @@ func (fs *FileSystem) Decompress(ctx context.Context, src, dst, encoding string) // 上传文件 fileStream, err := f.Open() if err != nil { - util.Log().Warning("无法打开压缩包内文件%s , %s , 跳过", rawPath, err) + util.Log().Warning("Failed to open file %q in archive file: %s, skipping...", rawPath, err) return nil } diff --git a/pkg/filesystem/file.go b/pkg/filesystem/file.go index 457e625..45f721c 100644 --- a/pkg/filesystem/file.go +++ b/pkg/filesystem/file.go @@ -72,7 +72,7 @@ func (fs *FileSystem) AddFile(ctx context.Context, parent *model.Folder, file fs if err != nil { if err := fs.Trigger(ctx, "AfterValidateFailed", file); err != nil { - util.Log().Debug("AfterValidateFailed 钩子执行失败,%s", err) + util.Log().Debug("AfterValidateFailed hook execution failed: %s", err) } return nil, ErrFileExisted.WithError(err) } @@ -203,7 +203,7 @@ func (fs *FileSystem) deleteGroupedFile(ctx context.Context, files map[uint][]*m // 取消上传会话 for _, upSession := range uploadSessions { if err := fs.Handler.CancelToken(ctx, upSession); err != nil { - util.Log().Warning("无法取消 [%s] 的上传会话: %s", upSession.Name, err) + util.Log().Warning("Failed to cancel upload session for %q: %s", upSession.Name, err) } cache.Deletes([]string{upSession.Key}, UploadSessionCachePrefix) @@ -270,14 +270,14 @@ func (fs *FileSystem) GetSource(ctx context.Context, fileID uint) (string, error if !fs.Policy.IsOriginLinkEnable { return "", serializer.NewError( serializer.CodePolicyNotAllowed, - "当前存储策略无法获得外链", + "This policy is not enabled for getting source link", nil, ) } source, err := fs.SignURL(ctx, &fs.FileTarget[0], 0, false) if err != nil { - return "", serializer.NewError(serializer.CodeNotSet, "无法获取外链", err) + return "", serializer.NewError(serializer.CodeNotSet, "Failed to get source link", err) } return source, nil @@ -298,7 +298,7 @@ func (fs *FileSystem) SignURL(ctx context.Context, file *model.File, ttl int64, siteURL := model.GetSiteURL() source, err := fs.Handler.Source(ctx, fs.FileTarget[0].SourceName, *siteURL, ttl, isDownload, fs.User.Group.SpeedLimit) if err != nil { - return "", serializer.NewError(serializer.CodeNotSet, "无法获取外链", err) + return "", serializer.NewError(serializer.CodeNotSet, "Failed to get source link", err) } return source, nil diff --git a/pkg/filesystem/filesystem.go b/pkg/filesystem/filesystem.go index b0da90e..f1745b6 100644 --- a/pkg/filesystem/filesystem.go +++ b/pkg/filesystem/filesystem.go @@ -203,7 +203,7 @@ func NewFileSystemFromCallback(c *gin.Context) (*FileSystem, error) { // 获取回调会话 callbackSessionRaw, ok := c.Get(UploadSessionCtx) if !ok { - return nil, errors.New("找不到回调会话") + return nil, errors.New("upload session not exist") } callbackSession := callbackSessionRaw.(*serializer.UploadSession) diff --git a/pkg/filesystem/hooks.go b/pkg/filesystem/hooks.go index 902dcce..4f3b9f2 100644 --- a/pkg/filesystem/hooks.go +++ b/pkg/filesystem/hooks.go @@ -44,7 +44,7 @@ func (fs *FileSystem) Trigger(ctx context.Context, name string, file fsctx.FileH for _, hook := range hooks { err := hook(ctx, fs, file) if err != nil { - util.Log().Warning("钩子执行失败:%s", err) + util.Log().Warning("Failed to execute hook:%s", err) return err } } @@ -112,7 +112,7 @@ func HookDeleteTempFile(ctx context.Context, fs *FileSystem, file fsctx.FileHead // 删除临时文件 _, err := fs.Handler.Delete(ctx, []string{file.Info().SavePath}) if err != nil { - util.Log().Warning("无法清理上传临时文件,%s", err) + util.Log().Warning("Failed to clean-up temp files: %s", err) } return nil diff --git a/pkg/filesystem/image.go b/pkg/filesystem/image.go index 30e80bf..493f8d7 100644 --- a/pkg/filesystem/image.go +++ b/pkg/filesystem/image.go @@ -71,16 +71,16 @@ func getThumbWorker() *Pool { thumbPool = &Pool{ worker: make(chan int, maxWorker), } - util.Log().Debug("初始化Thumb任务队列,WorkerNum = %d", maxWorker) + util.Log().Debug("Initialize thumbnails task queue with: WorkerNum = %d", maxWorker) }) return thumbPool } func (pool *Pool) addWorker() { pool.worker <- 1 - util.Log().Debug("Thumb任务队列,addWorker") + util.Log().Debug("Worker added to thumbnails task queue.") } func (pool *Pool) releaseWorker() { - util.Log().Debug("Thumb任务队列,releaseWorker") + util.Log().Debug("Worker released from thumbnails task queue.") <-pool.worker } @@ -107,7 +107,7 @@ func (fs *FileSystem) GenerateThumbnail(ctx context.Context, file *model.File) { image, err := thumb.NewThumbFromFile(source, file.Name) if err != nil { - util.Log().Warning("生成缩略图时无法解析 [%s] 图像数据:%s", file.SourceName, err) + util.Log().Warning("Cannot generate thumb because of failed to parse image %q: %s", file.SourceName, err) return } @@ -125,7 +125,7 @@ func (fs *FileSystem) GenerateThumbnail(ctx context.Context, file *model.File) { } if err != nil { - util.Log().Warning("无法保存缩略图:%s", err) + util.Log().Warning("Failed to save thumb: %s", err) return } diff --git a/pkg/filesystem/upload.go b/pkg/filesystem/upload.go index 50d22ff..9073ab2 100644 --- a/pkg/filesystem/upload.go +++ b/pkg/filesystem/upload.go @@ -69,7 +69,7 @@ func (fs *FileSystem) Upload(ctx context.Context, file *fsctx.FileStream) (err e followUpErr := fs.Trigger(ctx, "AfterValidateFailed", file) // 失败后再失败... if followUpErr != nil { - util.Log().Debug("AfterValidateFailed 钩子执行失败,%s", followUpErr) + util.Log().Debug("AfterValidateFailed hook execution failed: %s", followUpErr) } return err @@ -113,13 +113,13 @@ func (fs *FileSystem) CancelUpload(ctx context.Context, path string, file fsctx. // 客户端正常关闭,不执行操作 default: // 客户端取消上传,删除临时文件 - util.Log().Debug("客户端取消上传") + util.Log().Debug("Client canceled upload.") if fs.Hooks["AfterUploadCanceled"] == nil { return } err := fs.Trigger(ctx, "AfterUploadCanceled", file) if err != nil { - util.Log().Debug("执行 AfterUploadCanceled 钩子出错,%s", err) + util.Log().Debug("AfterUploadCanceled hook execution failed: %s", err) } }