MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / uploadWithMap

Function uploadWithMap

agent/app/service/backup.go:466–507  ·  view source on GitHub ↗
(taskItem task.Task, accountMap map[string]backupClientHelper, src, dst, accountIDs string, downloadAccountID, retry uint)

Source from the content-addressed store, hash-verified

464}
465
466func 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
509func newClient(account *model.BackupAccount, isEncrypt bool) (cloud_storage.CloudStorageClient, error) {
510 varMap := make(map[string]interface{})

Callers 6

handleAppMethod · 0.85
handleWebsiteMethod · 0.85
handleDatabaseMethod · 0.85
handleDirectoryMethod · 0.85
handleSystemLogMethod · 0.85
snapUploadFunction · 0.85

Calls 5

RemoveAllMethod · 0.80
UploadMethod · 0.65
LogFailedMethod · 0.45
LogStartMethod · 0.45
LogWithStatusMethod · 0.45

Tested by

no test coverage detected