(taskItem task.Task, accountMap map[string]backupClientHelper, src, dst, accountIDs string, downloadAccountID, retry uint)
| 464 | } |
| 465 | |
| 466 | func uploadWithMap(taskItem task.Task, accountMap map[string]backupClientHelper, src, dst, accountIDs string, downloadAccountID, retry uint) error { |
| 467 | accounts := strings.Split(accountIDs, ",") |
| 468 | for _, account := range accounts { |
| 469 | if len(account) == 0 { |
| 470 | continue |
| 471 | } |
| 472 | itemBackup, ok := accountMap[account] |
| 473 | if !ok { |
| 474 | continue |
| 475 | } |
| 476 | if itemBackup.hasBackup { |
| 477 | continue |
| 478 | } |
| 479 | if !itemBackup.isOk { |
| 480 | taskItem.LogFailed(i18n.GetMsgWithDetail("LoadBackupFailed", itemBackup.message)) |
| 481 | continue |
| 482 | } |
| 483 | name := itemBackup.name |
| 484 | if itemBackup.name == "localhost" { |
| 485 | name = i18n.GetMsgByKey("Localhost") |
| 486 | } |
| 487 | taskItem.LogStart(i18n.GetMsgWithMap("UploadFile", map[string]interface{}{ |
| 488 | "file": path.Join(itemBackup.backupPath, dst), |
| 489 | "backup": name, |
| 490 | })) |
| 491 | for i := 0; i < int(retry)+1; i++ { |
| 492 | _, err := itemBackup.client.Upload(src, path.Join(itemBackup.backupPath, dst)) |
| 493 | taskItem.LogWithStatus(i18n.GetMsgByKey("Upload"), err) |
| 494 | if err != nil { |
| 495 | if account == fmt.Sprintf("%d", downloadAccountID) { |
| 496 | return err |
| 497 | } |
| 498 | } else { |
| 499 | break |
| 500 | } |
| 501 | } |
| 502 | itemBackup.hasBackup = true |
| 503 | accountMap[account] = itemBackup |
| 504 | } |
| 505 | os.RemoveAll(src) |
| 506 | return nil |
| 507 | } |
| 508 | |
| 509 | func newClient(account *model.BackupAccount, isEncrypt bool) (cloud_storage.CloudStorageClient, error) { |
| 510 | varMap := make(map[string]interface{}) |
no test coverage detected