Start creating "persistent" blobs in cache directory

Helps #5515
// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-07-06 12:58:05 -07:00
parent 381237a315
commit 526d510423

View File

@ -151,9 +151,21 @@ public class PersistentBlobProvider {
}
private File getFile(long id) {
File legacy = getLegacyFile(id);
File cache = getCacheFile(id);
if (legacy.exists()) return legacy;
else return cache;
}
private File getLegacyFile(long id) {
return new File(context.getDir("captures", Context.MODE_PRIVATE), id + "." + BLOB_EXTENSION);
}
private File getCacheFile(long id) {
return new File(context.getCacheDir(), "capture-" + id + "." + BLOB_EXTENSION);
}
private @Nullable String getEncryptedFileName(@NonNull MasterSecret masterSecret, @Nullable String fileName) {
if (fileName == null) return null;
return new MasterCipher(masterSecret).encryptBody(fileName);