Skip to content

Add downloadSizeCallback before storing offline#3049

Merged
michellezhuogg merged 10 commits intoshaka-project:masterfrom
avelad:download-size-callback
Feb 1, 2021
Merged

Add downloadSizeCallback before storing offline#3049
michellezhuogg merged 10 commits intoshaka-project:masterfrom
avelad:download-size-callback

Conversation

@avelad
Copy link
Member

@avelad avelad commented Dec 15, 2020

Closes: #2900

@avelad
Copy link
Member Author

avelad commented Dec 22, 2020

@joeyparrish Do you think you could review it out for v3.1?

Comment on lines +555 to +559
} catch (e) {
throw new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.STORAGE,
shaka.util.Error.Code.OPERATION_ABORTED);
Copy link
Member

Choose a reason for hiding this comment

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

This is what happens if the callback throws, correct? I think in that case, we should at least log something, and maybe even use a different error code to make it clear what happened.

Copy link
Member Author

Choose a reason for hiding this comment

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

There are two causes here, the callback is asynchronous and it is I hope it returns a boolean, if it is false we should throw a "storage limit reached" error, in the case that an error is thrown (throw) I think the aborted operation is reasonable, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Joey, there should be at least a log, preferably a different error. Returning false already aborts the operation since we throw the STORAGE_LIMIT_REACHED error. This is more likely to happen if the app typed something wrong and we got a TypeError or something.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I will add a new error called DOWNLOAD_SIZE_CALLBACK_ERROR

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Can you review again?

@avelad avelad requested a review from joeyparrish December 23, 2020 20:17
@avelad
Copy link
Member Author

avelad commented Jan 20, 2021

@TheModMaker Could you review this PR?

Comment on lines +555 to +559
} catch (e) {
throw new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.STORAGE,
shaka.util.Error.Code.OPERATION_ABORTED);
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Joey, there should be at least a log, preferably a different error. Returning false already aborts the operation since we throw the STORAGE_LIMIT_REACHED error. This is more likely to happen if the app typed something wrong and we got a TypeError or something.

@avelad avelad requested a review from TheModMaker January 20, 2021 20:33
Copy link
Contributor

@michellezhuogg michellezhuogg left a comment

Choose a reason for hiding this comment

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

Are there any tests that need to be updated or added?

@avelad
Copy link
Member Author

avelad commented Jan 27, 2021

From my side I had no intention

@avelad avelad requested a review from michellezhuogg January 29, 2021 07:22
@avelad
Copy link
Member Author

avelad commented Feb 1, 2021

@michellezhuogg Is there something pending on your side? I would like this PR to be merged.

@michellezhuogg michellezhuogg merged commit 54b8f6e into shaka-project:master Feb 1, 2021
@avelad avelad deleted the download-size-callback branch February 1, 2021 20:21
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

status: archived Archived and locked; will not be updated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Query download size before storing offline

4 participants