Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -282,23 +282,22 @@ protected String doInBackground(Void... args) {

if (dbFile.getAbsolutePath().endsWith(".zip")) {
// uncompress first
try {
final FileInputStream fileInputStream = new FileInputStream(dbFile.getAbsolutePath());
final ZipInputStream zip_stream = new ZipInputStream(new BufferedInputStream(fileInputStream));
try (final FileInputStream fileInputStream = new FileInputStream(dbFile.getAbsolutePath());
final ZipInputStream zip_stream = new ZipInputStream(new BufferedInputStream(fileInputStream))) {
ZipEntry zipEntry = zip_stream.getNextEntry();
if ((zipEntry != null) && zipEntry.isDirectory())
zipEntry = zip_stream.getNextEntry();
if (zipEntry != null) {
String filename = zipEntry.getName();
if (filename.endsWith(".sqlite")) {
String output_filename = dbFile.getAbsolutePath().replaceFirst(".zip$", ".sqlite");
FileOutputStream fout = new FileOutputStream(output_filename);
byte[] buffer = new byte[4096];
int count = 0;
while ((count = zip_stream.read(buffer)) != -1) {
fout.write(buffer, 0, count);
try (FileOutputStream fout = new FileOutputStream(output_filename)) {
byte[] buffer = new byte[4096];
int count;
while ((count = zip_stream.read(buffer)) != -1) {
fout.write(buffer, 0, count);
}
}
fout.close();
dbFile = new File(output_filename);
delete_file = dbFile;
Log.d(TAG, "New filename: " + output_filename);
Expand All @@ -314,9 +313,6 @@ protected String doInBackground(Void... args) {
return msg;
}

zip_stream.close();
fileInputStream.close();

} catch (IOException e) {
String msg = "Could not open file";
JoH.static_toast_long(msg);
Expand Down
Loading