Skip to content

Commit

Permalink
fix error after restart API server for boolean parameters, fix #646
Browse files Browse the repository at this point in the history
  • Loading branch information
Slach committed Apr 24, 2023
1 parent 23510c6 commit 85f9895
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v2.2.5
- fix error after restart API server for boolean parameters, fix [646](https://github.com/AlexAkulov/clickhouse-backup/issues/646)

# v2.2.4
BUG FIXES
- fix wrong deletion on S3 for versioned buckets, use s3.HeadObject instead of s3.GetObjectAttributes, fix [643](https://github.com/AlexAkulov/clickhouse-backup/pull/643)
Expand Down
20 changes: 9 additions & 11 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1552,28 +1552,25 @@ func (api *APIServer) ResumeOperationsAfterRestart() error {
case "download":
case "upload":
args := make([]string, len(params)+2)
fullCommand := command
i := 0
args[i] = command
i++
if diffFrom, ok := params["diffFrom"]; ok && diffFrom.(string) != "" {
args[i] = fmt.Sprintf("--diff-from=\"%s\"", diffFrom)
fullCommand += " " + args[i]
i++
}
if diffFromRemote, ok := params["diffFromRemote"]; ok && diffFromRemote.(string) != "" {
args[i] = fmt.Sprintf("--diff-from-remote=\"%s\"", diffFromRemote)
fullCommand += " " + args[i]
i++
}

if tablePattern, ok := params["tablePattern"]; ok && tablePattern.(string) != "" {
args[i] = fmt.Sprintf("--tables=\"%s\"", tablePattern)
fullCommand += " " + args[i]
i++
}

if schemaOnly, ok := params["schemaOnly"]; ok && schemaOnly.(bool) {
args[i] = "--schema"
fullCommand += " " + args[i]
args[i] = "--schema=1"
i++
}

Expand All @@ -1582,13 +1579,14 @@ func (api *APIServer) ResumeOperationsAfterRestart() error {
for j, v := range partitions.([]interface{}) {
partitionsStr[j] = v.(string)
}
args[i] = fmt.Sprintf(" --partitions=\"%s\"", strings.Join(partitionsStr, ","))
fullCommand += " " + args[i]
args[i] = fmt.Sprintf("--partitions=\"%s\"", strings.Join(partitionsStr, ","))
i++
}
args[i] = "--resumable"
args[i+1] = backupName
fullCommand += " --resumable " + backupName
args[i] = "--resumable=1"
i++
args[i] = backupName
args = args[:i+1]
fullCommand := strings.Join(args, " ")
api.log.WithField("operation", "ResumeOperationsAfterRestart").Info(fullCommand)
commandId, _ := status.Current.Start(fullCommand)
err, _ = api.metrics.ExecuteWithMetrics(command, 0, func() error {
Expand Down

0 comments on commit 85f9895

Please sign in to comment.