Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
f7177be3
Commit
f7177be3
authored
Mar 13, 2026
by
Rose Ding
Browse files
fix: golangci-lint 修复(gofmt 格式化 + errcheck 返回值检查)
Co-Authored-By:
Claude Opus 4.6
<
noreply@anthropic.com
>
parent
875b417f
Changes
1
Hide whitespace changes
Inline
Side-by-side
backend/internal/service/backup_service.go
View file @
f7177be3
...
@@ -43,13 +43,13 @@ var (
...
@@ -43,13 +43,13 @@ var (
// BackupS3Config S3 兼容存储配置(支持 Cloudflare R2)
// BackupS3Config S3 兼容存储配置(支持 Cloudflare R2)
type
BackupS3Config
struct
{
type
BackupS3Config
struct
{
Endpoint
string
`json:"endpoint"`
// e.g. https://<account_id>.r2.cloudflarestorage.com
Endpoint
string
`json:"endpoint"`
// e.g. https://<account_id>.r2.cloudflarestorage.com
Region
string
`json:"region"`
// R2 用 "auto"
Region
string
`json:"region"`
// R2 用 "auto"
Bucket
string
`json:"bucket"`
Bucket
string
`json:"bucket"`
AccessKeyID
string
`json:"access_key_id"`
AccessKeyID
string
`json:"access_key_id"`
SecretAccessKey
string
`json:"secret_access_key,omitempty"`
SecretAccessKey
string
`json:"secret_access_key,omitempty"`
//nolint:revive // field name follows AWS convention
Prefix
string
`json:"prefix"`
// S3 key 前缀,如 "backups/"
Prefix
string
`json:"prefix"`
// S3 key 前缀,如 "backups/"
ForcePathStyle
bool
`json:"force_path_style"`
ForcePathStyle
bool
`json:"force_path_style"`
}
}
// IsConfigured 检查必要字段是否已配置
// IsConfigured 检查必要字段是否已配置
...
@@ -60,16 +60,16 @@ func (c *BackupS3Config) IsConfigured() bool {
...
@@ -60,16 +60,16 @@ func (c *BackupS3Config) IsConfigured() bool {
// BackupScheduleConfig 定时备份配置
// BackupScheduleConfig 定时备份配置
type
BackupScheduleConfig
struct
{
type
BackupScheduleConfig
struct
{
Enabled
bool
`json:"enabled"`
Enabled
bool
`json:"enabled"`
CronExpr
string
`json:"cron_expr"`
// cron 表达式,如 "0 2 * * *" 每天凌晨2点
CronExpr
string
`json:"cron_expr"`
// cron 表达式,如 "0 2 * * *" 每天凌晨2点
RetainDays
int
`json:"retain_days"`
// 备份文件过期天数,默认14,0=不自动清理
RetainDays
int
`json:"retain_days"`
// 备份文件过期天数,默认14,0=不自动清理
RetainCount
int
`json:"retain_count"`
// 最多保留份数,0=不限制
RetainCount
int
`json:"retain_count"`
// 最多保留份数,0=不限制
}
}
// BackupRecord 备份记录
// BackupRecord 备份记录
type
BackupRecord
struct
{
type
BackupRecord
struct
{
ID
string
`json:"id"`
ID
string
`json:"id"`
Status
string
`json:"status"`
// pending, running, completed, failed
Status
string
`json:"status"`
// pending, running, completed, failed
BackupType
string
`json:"backup_type"`
// postgres
BackupType
string
`json:"backup_type"`
// postgres
FileName
string
`json:"file_name"`
FileName
string
`json:"file_name"`
S3Key
string
`json:"s3_key"`
S3Key
string
`json:"s3_key"`
SizeBytes
int64
`json:"size_bytes"`
SizeBytes
int64
`json:"size_bytes"`
...
@@ -85,11 +85,11 @@ type BackupService struct {
...
@@ -85,11 +85,11 @@ type BackupService struct {
settingRepo
SettingRepository
settingRepo
SettingRepository
dbCfg
*
config
.
DatabaseConfig
dbCfg
*
config
.
DatabaseConfig
mu
sync
.
Mutex
mu
sync
.
Mutex
s3Client
*
s3
.
Client
s3Client
*
s3
.
Client
s3Cfg
*
BackupS3Config
s3Cfg
*
BackupS3Config
backingUp
bool
backingUp
bool
restoring
bool
restoring
bool
cronMu
sync
.
Mutex
cronMu
sync
.
Mutex
cronSched
*
cron
.
Cron
cronSched
*
cron
.
Cron
...
@@ -454,14 +454,14 @@ func (s *BackupService) RestoreBackup(ctx context.Context, backupID string) erro
...
@@ -454,14 +454,14 @@ func (s *BackupService) RestoreBackup(ctx context.Context, backupID string) erro
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"S3 download failed: %w"
,
err
)
return
fmt
.
Errorf
(
"S3 download failed: %w"
,
err
)
}
}
defer
result
.
Body
.
Close
()
defer
func
()
{
_
=
result
.
Body
.
Close
()
}()
// 解压 gzip
// 解压 gzip
gzReader
,
err
:=
gzip
.
NewReader
(
result
.
Body
)
gzReader
,
err
:=
gzip
.
NewReader
(
result
.
Body
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"gzip reader: %w"
,
err
)
return
fmt
.
Errorf
(
"gzip reader: %w"
,
err
)
}
}
defer
gzReader
.
Close
()
defer
func
()
{
_
=
gzReader
.
Close
()
}()
sqlData
,
err
:=
io
.
ReadAll
(
gzReader
)
sqlData
,
err
:=
io
.
ReadAll
(
gzReader
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment