Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/app/service/cronjob_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ func (u *CronjobService) uploadCronjobBackFile(cronjob model.Cronjob, accountMap
if len(account) != 0 {
global.LOG.Debugf("start upload file to %s, dir: %s", account, path.Join(accountMap[account].backupPath, cloudSrc))
if _, err := accountMap[account].client.Upload(file, path.Join(accountMap[account].backupPath, cloudSrc)); err != nil {
return "", err
global.LOG.Errorf("upload file to %s failed, err: %v", account, err)
continue
}
global.LOG.Debugf("upload successful!")
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code changes introduce logging for errors during uploads and continue processing if an error occurs. This improves debugging by providing more context about what failed to upload rather than terminating the process immediately without informing developers of issues.

Explanation:

  1. Logging Errors: By adding global.LOG.Errorf(...) instead of just returning early with err, the program logs the specific error that occurred when attempting to upload a file. This helps in diagnosing problems later on.

  2. Continuing Processing: The line continue allows the program to proceed with uploading other files even if one fails. This avoids stopping execution prematurely due to a single failure, which could be beneficial in scenarios where multiple backups are uploaded simultaneously.

Optimization Suggestions:
If you want to optimize further beyond this basic improvement, consider handling cases where many accounts fail to upload their respective files simultaneously gracefully. You might log warnings or take measures to retry uploads after certain intervals depending on needs.

Overall, these changes improve error management and robustness by providing useful feedback without aborting normal operations.

Expand Down
Loading