Commit 8e9566f2 authored by Bastien Le Querrec's avatar Bastien Le Querrec

avoid NPE when exporting data, do not backup lib/

Also, throw IOException on NPE. This should not append because NPE
occurs on some devices when copying lib/. But in case of another corner
case with NPEs, this commit will prevent a crash and log info.

Fixes #631
parent 69d3d635
......@@ -83,6 +83,7 @@ public class EncryptedBackupExporter {
}
private static void exportDirectory(Context context, String directoryName) throws IOException {
if (!directoryName.equals("/lib")) {
File directory = new File(context.getFilesDir().getParent() + File.separatorChar + directoryName);
File exportDirectory = new File(getExportDirectoryPath() + File.separatorChar + directoryName);
......@@ -91,6 +92,9 @@ public class EncryptedBackupExporter {
File[] contents = directory.listFiles();
if (contents == null)
throw new IOException("directory.listFiles() is null for " + context.getFilesDir().getParent() + File.separatorChar + directoryName + "!");
for (int i=0;i<contents.length;i++) {
File localFile = contents[i];
......@@ -105,6 +109,7 @@ public class EncryptedBackupExporter {
Log.w(TAG, "Could not find directory: " + directory.getAbsolutePath() + " (or it is not a directory)");
}
}
}
private static void importDirectory(Context context, String directoryName) throws IOException {
File directory = new File(getExportDirectoryPath() + File.separator + directoryName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment