Skip to content
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

Open
wants to merge 1 commit into
base: purgatory
Choose a base branch
from
Open

bigger files in sqlite #165

wants to merge 1 commit into from

Conversation

krisoft
Copy link

@krisoft krisoft commented Jan 4, 2016

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)

…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) {
Copy link
Member

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()

Copy link
Member

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);
      }
   }

Copy link
Author

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.

@DiegoGomezDeck
Copy link
Member

@krisoft any advances in this PR?

@krisoft
Copy link
Author

krisoft commented Feb 16, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants