sftpgo icon indicating copy to clipboard operation
sftpgo copied to clipboard

metric: treat io.EOF as successful upload, not an error

Open lushenle opened this issue 6 months ago • 2 comments

This pull request introduces enhancements to the internal/metric/metric.go file, focusing on error handling and dependency updates. The changes improve the robustness of metrics tracking by accounting for additional error scenarios and updating imports.

Error handling improvements:

  • Modified the TransferCompleted function to increment totalUploads even when the error is io.EOF, ensuring proper metrics tracking for completed transfers despite this specific error condition.

Dependency updates:

  • Added imports for errors and io packages to support the new error handling logic in the TransferCompleted function.Uploads that end with io.EOF are now considered successful and no longer increment the upload error metric. This aligns metric reporting with Go convention, where io.EOF indicates normal completion rather than an error.

Checklist for Pull Requests


lushenle avatar Jun 19 '25 13:06 lushenle

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


lushenle seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Jun 19 '25 13:06 CLAassistant

If an upload returns EOF, you will have a partial file or no file at all, depending on the storage backend and the SFTPGo configuration

drakkan avatar Jul 20 '25 09:07 drakkan