Skip to content

Commit 921453e

Browse files
Andyporrasjamescr
authored andcommitted
Fix: create zip without multimedia
1 parent 230f05e commit 921453e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

app/src/main/java/net/osmtracker/gpx/ZipHelper.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ public static File zipCacheFiles(Context context, long trackId, File fileGPX) {
3636
try (FileOutputStream fos = new FileOutputStream(zipFile);
3737
ZipOutputStream zos = new ZipOutputStream(fos)) {
3838

39+
// Add gpx file
40+
addFileToZip(fileGPX, zos);
41+
42+
if(!traceFilesDirectory.exists()){
43+
return zipFile;
44+
}
45+
3946
for (File multimediaFile : Objects.requireNonNull(traceFilesDirectory.listFiles())) {
4047
if (!multimediaFile.isDirectory()) { // Avoid adding empty folders
4148
// only add files that are not .zip files
@@ -49,9 +56,6 @@ public static File zipCacheFiles(Context context, long trackId, File fileGPX) {
4956
}
5057
}
5158

52-
// Adds the original gpx file
53-
addFileToZip(fileGPX, zos);
54-
5559
Log.d(TAG, "ZIP file created: " + zipFile.getAbsolutePath());
5660
return zipFile;
5761

@@ -87,4 +91,4 @@ private static void addFileToZip(File file, ZipOutputStream zos) throws IOExcept
8791
zos.closeEntry();
8892
}
8993
}
90-
}
94+
}

0 commit comments

Comments
 (0)