Skip to content

Commit 1711414

Browse files
committed
Don't zip exported files when exporting to a URI (SAF)
As with Storage Access Framework we are limited to one file, we checked if there were multiple files to export and packed them into a ZIP file. This only happened when exporting to QIF, which now packs multiple files into a ZIP. Other export formats were already generating a single file. So now we just copy the exported file.
1 parent c4f6a26 commit 1711414

1 file changed

Lines changed: 3 additions & 18 deletions

File tree

app/src/main/java/org/gnucash/android/export/ExportAsyncTask.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -283,25 +283,10 @@ private void moveExportToUri() throws Exporter.ExporterException {
283283
if (mExportedFiles.size() > 0){
284284
try {
285285
OutputStream outputStream = mContext.getContentResolver().openOutputStream(exportUri);
286-
ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);
287-
byte[] buffer = new byte[1024];
288-
for (String exportedFile : mExportedFiles) {
289-
File file = new File(exportedFile);
290-
FileInputStream fileInputStream = new FileInputStream(file);
291-
zipOutputStream.putNextEntry(new ZipEntry(file.getName()));
292-
293-
int length;
294-
while ((length = fileInputStream.read(buffer)) > 0) {
295-
zipOutputStream.write(buffer, 0, length);
296-
}
297-
zipOutputStream.closeEntry();
298-
fileInputStream.close();
299-
}
300-
zipOutputStream.close();
286+
// Now we always get just one file exported (QIFs are zipped)
287+
moveFile(mExportedFiles.get(0), outputStream);
301288
} catch (IOException ex) {
302-
Log.e(TAG, "Error when zipping QIF files for export");
303-
ex.printStackTrace();
304-
Crashlytics.logException(ex);
289+
throw new Exporter.ExporterException(mExportParams, "Error when moving file to URI");
305290
}
306291
}
307292
}

0 commit comments

Comments
 (0)