支持迁移对象存储到 OSS
This commit is contained in:
@@ -333,6 +333,26 @@ func New(cfg config.Config, deps Dependencies, logger *zap.Logger) *gin.Engine {
|
||||
if err != nil {
|
||||
logger.Warn("文件存储桶尚未就绪,接口请求时将重试", zap.Error(err))
|
||||
}
|
||||
if cfg.StorageMirror.Endpoint != "" {
|
||||
mirrorStorage, mirrorErr := filemodule.NewStorage(cfg.StorageMirror)
|
||||
if fileStorage != nil {
|
||||
// 客户端已创建时,即使启动检查失败也由上传请求重新探测 Bucket。
|
||||
if mirrorStorage != nil {
|
||||
fileStorage.SetMirror(mirrorStorage, nil)
|
||||
} else {
|
||||
fileStorage.SetMirror(nil, mirrorErr)
|
||||
}
|
||||
}
|
||||
if mirrorErr != nil {
|
||||
if mirrorStorage != nil {
|
||||
logger.Warn("文件存储镜像启动检查失败,上传时将重试", zap.Error(mirrorErr))
|
||||
} else {
|
||||
logger.Error("文件存储镜像客户端创建失败,已阻止新文件上传", zap.Error(mirrorErr))
|
||||
}
|
||||
} else {
|
||||
logger.Info("文件存储镜像已启用")
|
||||
}
|
||||
}
|
||||
}
|
||||
fileService := filemodule.NewService(fileStorage)
|
||||
fileHandler := filemodule.NewHandler(fileService, fileStorage)
|
||||
|
||||
Reference in New Issue
Block a user