-
Notifications
You must be signed in to change notification settings - Fork 18
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
CancelUpload only works if the upload is already paused #33
Comments
Hi Josef, We could definitely have a conversation about the best order which the upload callbacks get called. I'll give you a quick rundown about the reasoning behind this behavior, and If you have some ideas about callback ordering or APIs in general, let me know. Since cancellation could happen at any time while the upload is in progress, the private final McuMgrCallback<McuMgrImageUploadResponse> mUploadCallbackImpl =
new McuMgrCallback<McuMgrImageUploadResponse>() {
@Override
public void onResponse(@NotNull McuMgrImageUploadResponse response) {
// ...
// Call the progress callback.
mUploadCallback.onProgressChanged(mUploadOffset, mImageData.length,
System.currentTimeMillis());
if (mUploadState == STATE_NONE) {
LOG.debug("Upload canceled!");
resetUpload();
mUploadCallback.onUploadCanceled();
mUploadCallback = null;
return;
}
// ...
} The progress callback is called before the cancellation callback because the upload has progressed to that point. I believe we felt that we would be losing some information if upload cancelled immediately while a command was in transit, hence the reason why the All that aside, simply making that change in your original post may have unintended consequences (e.g. null pointer exceptions). But if you feel strongly about immediate cancellation, I am happy to review a PR. Proposed Solution (#32)I currently have a PR open for refactoring and abstracting all transfers (uploads and downloads) outside of the individual managers (#32). This would replace the current upload/download implementations in Brian |
Hi!
Yes, for our application the next transferred frame does not matter at all once the decision to cancel the transfer is made. Therefore i would have guessed that
I am wrapping the
Sounds like a good idea, however i have glanced through your PR and i think that your PR is unrelated to the issue i raise here. So, design wise i would still vote for an implementation that immediately cancels transfers when using the Thank you for your time! Cheers Josef |
Hello everyone!
Using the
ImageManager
i tried to cancel a upload using itscancelUpload()
method, but i still got callbacks after doing so. I inspected the code and saw that the upload is only fully cancelled if the file transfer was paused to begin with:My question: Is this the intended design? - Shouldn't the upload be cancelled also if the upload is currently in progress and not paused? Like so:
I can create a PR if you'd like.
Thanks
The text was updated successfully, but these errors were encountered: