-
Notifications
You must be signed in to change notification settings - Fork 56
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
bigger files in sqlite #165
base: purgatory
Are you sure you want to change the base?
Conversation
…gger data files by saving them separately and saving a pointer into the database
try { | ||
fin = new FileInputStream(f2); | ||
final int avail = fin.available(); | ||
if (avail == 0) { |
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'm quiet sure this use of available() method is wrong.
Take a look to this:
https://docs.oracle.com/javase/7/docs/api/java/io/FileInputStream.html#available()
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.
You need something like:
public static byte[] readAll(final InputStream is) throws IOException {
final ByteArrayOutputStream result = new ByteArrayOutputStream();
final byte[] buffer = new byte[16384];
int read;
while ((read = is.read(buffer, 0, buffer.length)) != -1) {
result.write(buffer, 0, read);
}
result.flush();
return result.toByteArray();
}
public static byte[] readAll(final File file) throws IOException {
try (final FileInputStream is = new FileInputStream(file)) {
return readAll(is);
}
}
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.
Thank you very much @DiegoGomezDeck! Looks very much like you are right. I will consult with @DrakkLord and one of us will fix this.
@krisoft any advances in this PR? |
It's in our worklog, but the feature on our side which depends on this got a lower priority. So it might take a while until we come around fixing the issues you so kindly pointed out for us. I hope that doesn't cause any trouble. |
Added ability to the android sql cache store to be able to contain bigger data files by saving them separately and saving a pointer into the database.
(This has been broken out from #153)