JamitLabs / Jetworking

A multi-module library providing a user-friendly interface for common networking tasks
https://JamitLabs.github.io/Jetworking/
MIT License
4 stars 3 forks source link

DownloadHandler.CompletionHandler called twice #57

Open jamitJona opened 3 years ago

jamitJona commented 3 years ago

If a download via the download method in Client succeeds the completion handler is called twice:

The first call is triggered by downloadExecutor(_ downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL). The second by downloadExecutor(_ downloadTask: URLSessionDownloadTask, didCompleteWithError error: Error?) with error = nil.

Since download(url: URL, progressHandler: DownloadHandler.ProgressHandler, _ completion: @escaping DownloadHandler.CompletionHandler) offers a completion handler (and not some delegation), completion should only called once after the internal downloadTask has finished.