Use temporary folder for encryption

This commit is contained in:
M66B 2021-02-20 08:46:23 +01:00
parent 95fc3913df
commit d3805dc80b
2 changed files with 14 additions and 4 deletions

View File

@ -2320,8 +2320,11 @@ public class FragmentCompose extends FragmentBase {
throw new IllegalArgumentException(context.getString(R.string.title_from_missing)); throw new IllegalArgumentException(context.getString(R.string.title_from_missing));
// Create files // Create files
File input = new File(context.getCacheDir(), "pgp_input." + draft.id); File tmp = new File(context.getFilesDir(), "encryption");
File output = new File(context.getCacheDir(), "pgp_output." + draft.id); if (!tmp.exists())
tmp.mkdir();
File input = new File(tmp, draft.id + ".pgp_input");
File output = new File(tmp, draft.id + ".pgp_output");
// Serializing messages is NOT reproducible // Serializing messages is NOT reproducible
if ((EntityMessage.PGP_SIGNONLY.equals(draft.ui_encrypt) && if ((EntityMessage.PGP_SIGNONLY.equals(draft.ui_encrypt) &&
@ -2652,6 +2655,10 @@ public class FragmentCompose extends FragmentBase {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean check_certificate = prefs.getBoolean("check_certificate", true); boolean check_certificate = prefs.getBoolean("check_certificate", true);
File tmp = new File(context.getFilesDir(), "encryption");
if (!tmp.exists())
tmp.mkdir();
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
// Get data // Get data
@ -2777,7 +2784,7 @@ public class FragmentCompose extends FragmentBase {
.build(contentSigner, chain[0]); .build(contentSigner, chain[0]);
cmsGenerator.addSignerInfoGenerator(signerInfoGenerator); cmsGenerator.addSignerInfoGenerator(signerInfoGenerator);
File sinput = new File(context.getCacheDir(), "smime_sign." + draft.id); File sinput = new File(tmp, draft.id + ".smime_sign");
try (FileOutputStream fos = new FileOutputStream(sinput)) { try (FileOutputStream fos = new FileOutputStream(sinput)) {
bpContent.writeTo(fos); bpContent.writeTo(fos);
} }
@ -2895,7 +2902,7 @@ public class FragmentCompose extends FragmentBase {
} }
} }
File einput = new File(context.getCacheDir(), "smime_encrypt." + draft.id); File einput = new File(tmp, draft.id + ".smime_encrypt");
try (FileOutputStream fos = new FileOutputStream(einput)) { try (FileOutputStream fos = new FileOutputStream(einput)) {
imessage.writeTo(fos); imessage.writeTo(fos);
} }

View File

@ -191,6 +191,7 @@ public class WorkerCleanup extends Worker {
File[] messages = new File(context.getFilesDir(), "messages").listFiles(); File[] messages = new File(context.getFilesDir(), "messages").listFiles();
File[] revision = new File(context.getFilesDir(), "revision").listFiles(); File[] revision = new File(context.getFilesDir(), "revision").listFiles();
File[] references = new File(context.getFilesDir(), "references").listFiles(); File[] references = new File(context.getFilesDir(), "references").listFiles();
File[] encryption = new File(context.getFilesDir(), "encryption").listFiles();
File[] photos = new File(context.getCacheDir(), "photo").listFiles(); File[] photos = new File(context.getCacheDir(), "photo").listFiles();
File[] calendars = new File(context.getCacheDir(), "calendar").listFiles(); File[] calendars = new File(context.getCacheDir(), "calendar").listFiles();
@ -200,6 +201,8 @@ public class WorkerCleanup extends Worker {
files.addAll(Arrays.asList(revision)); files.addAll(Arrays.asList(revision));
if (references != null) if (references != null)
files.addAll(Arrays.asList(references)); files.addAll(Arrays.asList(references));
if (encryption != null)
files.addAll(Arrays.asList(encryption));
if (photos != null) if (photos != null)
files.addAll(Arrays.asList(photos)); files.addAll(Arrays.asList(photos));
if (calendars != null) if (calendars != null)