Skip to content

Guard upload progress when total size is unknown#158

Closed
zerox80 wants to merge 3 commits into
opencloud-eu:mainfrom
zerox80:zerox80/fix-upload-progress-unknown-total
Closed

Guard upload progress when total size is unknown#158
zerox80 wants to merge 3 commits into
opencloud-eu:mainfrom
zerox80:zerox80/fix-upload-progress-unknown-total

Conversation

@zerox80
Copy link
Copy Markdown
Contributor

@zerox80 zerox80 commented May 12, 2026

Summary

  • avoid invalid progress percentages when upload size is unknown or zero
  • clamp calculated upload progress to the valid 0 to 100 range
  • apply the same behavior to filesystem and content URI uploads

Tests

  • Added unit coverage for zero, unknown, normal, and over-complete progress values

@guruz
Copy link
Copy Markdown
Contributor

guruz commented May 18, 2026

This is for uploads? In which case would the size be not known by us?

@zerox80
Copy link
Copy Markdown
Contributor Author

zerox80 commented May 18, 2026

Yes, this is upload progress. In the current worker flow we should normally know the size: filesystem uploads use File.length(), content URI uploads are copied to a cache file first and then use that cached file length, and TUS sends Upload-Length. Core also requires Upload-Length for TUS creation, so unknown size is not an expected OpenCloud upload path.

The <=0 guard is mainly defensive for invalid progress callback totals / zero-size edge cases. The practical fix here is also clamping over-complete values to 100.

@zerox80 zerox80 closed this May 18, 2026
@zerox80
Copy link
Copy Markdown
Contributor Author

zerox80 commented May 18, 2026

backend / reva sends 412 if file size unknown, so this PR can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants