Skip to content

Commit 95866ff

Browse files
author
Акулов Александр Яковлевич
committed
small refactoring
1 parent 8d93db4 commit 95866ff

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

main.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import (
1414
"github.com/urfave/cli"
1515
)
1616

17-
const BackupTimeFormat = "2006-01-02T15-04-05"
17+
const (
18+
BackupTimeFormat = "2006-01-02T15-04-05"
19+
defaultConfigPath = "/etc/clickhouse-backup/config.yml"
20+
)
1821

1922
var (
2023
version = "unknown"
@@ -24,10 +27,6 @@ var (
2427
ErrUnknownClickhouseDataPath = errors.New("clickhouse data path is unknown, you can set data_path in config file")
2528
)
2629

27-
const (
28-
defaultConfigPath = "/etc/clickhouse-backup/config.yml"
29-
)
30-
3130
func main() {
3231
log.SetOutput(os.Stdout)
3332
cliapp := cli.NewApp()

s3.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,18 @@ func (s *S3) UploadDirectory(localPath string, dstPath string) error {
237237
}
238238

239239
// UploadFile - synchronize localPath to dstPath on s3
240-
func (s *S3) UploadFile(config *Config, localPath string, dstPath string) error {
240+
func (s *S3) UploadFile(localPath string, dstPath string) error {
241241
uploader := s3manager.NewUploader(s.session)
242-
uploader.PartSize = config.S3.PartSize
242+
uploader.PartSize = s.Config.PartSize
243243

244244
file, err := os.Open(localPath)
245245
if err != nil {
246246
return fmt.Errorf("error opening file %v: %v", localPath, err)
247247
}
248248
if !s.DryRun {
249249
if _, err := uploader.UploadWithContext(aws.BackgroundContext(), &s3manager.UploadInput{
250-
ACL: aws.String(config.S3.ACL),
251-
Bucket: aws.String(config.S3.Bucket),
250+
ACL: aws.String(s.Config.ACL),
251+
Bucket: aws.String(s.Config.Bucket),
252252
Key: aws.String(path.Join(s.Config.Path, dstPath)),
253253
Body: file,
254254
}); err != nil {

0 commit comments

Comments
 (0)