Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/response header in did finish upload delegate #167

Conversation

srvarma7
Copy link
Contributor

No description provided.

@srvarma7
Copy link
Contributor Author

@Acconut @donnywals
This is the conflict resolved PR for closed PR.
I've made some improvements and was having a trouble with branch name change (master -> main) with the last PR. Hence closed.
Thank you.

@@ -16,7 +16,7 @@ public protocol TUSClientDelegate: AnyObject {
/// TUSClient is starting an upload
func didStartUpload(id: UUID, context: [String: String]?, client: TUSClient)
/// `TUSClient` just finished an upload, returns the URL of the uploaded file.
func didFinishUpload(id: UUID, url: URL, context: [String: String]?, client: TUSClient)
func didFinishUpload(id: UUID, url: URL, responseHeaders: [String: String]?, context: [String: String]?, client: TUSClient)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Adding support for response headers this way makes this PR a breaking change which I want to avoid.

We could have both versions of didFinishUpload with and without the responseHeaders defined on this protocol. Both would need to be called from the places where we call delegate?.didFinishUpload which would be error prone so expanding the test suite to verify we always call both would be desirable.

If you have other ideas to implement this as a non-breaking change, I'm all ears 👍🏼

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made the above change making func didFinishUpload(id: UUID, url: URL, context: [String: String]?, client: TUSClient, responseHeaders: [String: String]?) an optional function and called both the functions in a private function.
In the mock test, I've just added a skeleton that confirms to the optional delegate method. Could you please suggest me to how to make the test case work with the changes?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll try and take a detailed look at that later this week, possibly next week. I'm currently on vacation so only have very short bursts of time to look at PRs and do bits of work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Have a nice vacation.
Will be looking forward for your feedback after your vacation.

@@ -40,6 +40,11 @@ public extension TUSClientDelegate {
func progressFor(id: UUID, context: [String: String]?, progress: Float, client: TUSClient) {
// Optional
}

/// `TUSClient` just finished an upload, returns the URL of the uploaded file along with `responseHeaders` from server.
func didFinishUpload(id: UUID, url: URL, context: [String: String]?, client: TUSClient, responseHeaders: [String: String]?) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I actually think this would still be breaking since if I conform to the delegate protocol I must implement all methods required by the protocol. This slipped my mind earlier.

Maybe we can provide a default empty implementation in a protocol extension for this method so that existing users of the SDK wouldn't have to do any work after updating?

I do wonder if we could mark a protocol method as deprecated. If we can, we could deprecate the old one and tell clients to implement the new method

Addition of didFinishUpload with responseHeader in TUSClientDelegate protocol definition.
@kvz
Copy link
Member

kvz commented Sep 26, 2024

Hi, should we close this?

@donnywals
Copy link
Collaborator

Will close due to inactivity

@donnywals donnywals closed this Oct 3, 2024
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.

3 participants