-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Update ContentDataSource.java #3428
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,7 @@ public long open(DataSpec dataSpec) throws ContentDataSourceException { | |
long assetFileDescriptorLength = assetFileDescriptor.getLength(); | ||
if (assetFileDescriptorLength == AssetFileDescriptor.UNKNOWN_LENGTH) { | ||
// The asset must extend to the end of the file. | ||
bytesRemaining = inputStream.available(); | ||
bytesRemaining = ((FileInputStream) inputStream).getChannel().size(); | ||
if (bytesRemaining == 0) { | ||
// FileInputStream.available() returns 0 if the remaining length cannot be determined, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment doesn't seem to make sense given then change being made? Does the if block itself still make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bytesRemaining = inputStream.available()
bytesRemaining = ((FileInputStream) inputStream).getChannel().size();
Again. I do not understand, why you asking this. Propbably need more testing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the previous code we actually called |
||
// or if it's greater than Integer.MAX_VALUE. We don't know the true length in either | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's possible for multiple assets to be in a single file. In which case is
size()
the size of just this one, or of all of them? I think you might want to subtractposition()
of theFileChannel
to get correct behavior?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what do you mean, FileChannel one per file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the
uri
for which the source is being opened necessarily corresponds to the whole file though. Else this code wouldn't need to be usingassetFileDescriptor.getStartOffset
as above? If theuri
only corresponds to a part of the file, that needs to be accounted for.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if the
uri
does correspond to the whole file, you'd need to subtractskipped
if it's non-zero.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then correct line is:
bytesRemaining = ((FileInputStream) inputStream).getChannel().size() - assetFileDescriptor.getStartOffset