Skip to content

Add server-side UploadCompletionListener and return UploadInfo from process() - #125

Merged
tomdesair merged 4 commits into
masterfrom
feature/upload-completion-listener
Aug 29, 2026
Merged

Add server-side UploadCompletionListener and return UploadInfo from process()#125
tomdesair merged 4 commits into
masterfrom
feature/upload-completion-listener

Conversation

@tomdesair

Copy link
Copy Markdown
Owner

Description

This pull request introduces a server-side upload completion callback mechanism and updates TusFileUploadService.process(...) to return the processed UploadInfo.

Summary of Changes

  1. UploadCompletionListener Functional Interface:
    • Introduced @FunctionalInterface public interface UploadCompletionListener with void onUploadComplete(UploadInfo uploadInfo, TusFileUploadService tusFileUploadService).
    • Added registration methods withUploadCompletionListener(UploadCompletionListener) and addUploadCompletionListener(UploadCompletionListener) to TusFileUploadService.
  2. Lock Release Before Callback Execution:
    • Evaluates initial progress state (wasInProgress) and triggers listeners when transitioning to complete.
    • The upload lock is released before listeners are executed, allowing listeners to safely call service.getUploadedBytes(uploadInfo) or service.deleteUpload(uploadInfo) without lock contention or UploadAlreadyLockedException.
    • Listener exceptions are isolated so downstream errors do not abort other listeners or corrupt HTTP responses.
  3. process() Return Value & Convenience Overloads:
    • TusFileUploadService.process(...) now returns the created or updated UploadInfo (or null on errors / OPTIONS).
    • Added TusFileUploadService.getUploadedBytes(UploadInfo) and TusFileUploadService.deleteUpload(UploadInfo) convenience methods.
  4. Testing:
    • Unit tests in UploadCompletionListenerTest.java (8 unit tests).
    • Multi-backend integration tests in AbstractITTusFileUploadService.java and AbstractITRufhProtocol.java covering Tus PATCH, creation-with-upload, concatenation, and RUFH optimistic POST / PATCH appends across Disk, S3, and Azure Blob storage.
  5. Documentation & Changelog:
    • Updated README.md with configuration options, session upload ID association examples (Creation vs. Progress check pattern), listener usage, and single-request lifecycle timing notes.
    • Updated CHANGELOG.md under ## [2.0.0].

Verification

  • mvn clean install -q: ✅ PASSED
  • Unit and Multi-Backend Integration Tests: ✅ PASSED
  • python3 scripts/check-coverage.py --per-file-limit 90: ✅ PASSED (Diff coverage: 97.60%, all files > 90%)
  • Code style formatting: ✅ PASSED

@coveralls

coveralls commented Aug 29, 2026

Copy link
Copy Markdown

Coverage Status

Coverage is 94.609%feature/upload-completion-listener into master. No base build found for master.

@tomdesair
tomdesair merged commit 9422ca6 into master Aug 29, 2026
13 checks passed
@tomdesair
tomdesair deleted the feature/upload-completion-listener branch August 29, 2026 13:46
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