Retain latest 2 instead of latest 5 backups

Fixes #7650
This commit is contained in:
Moxie Marlinspike 2018-04-06 08:42:58 -07:00
parent 4669c45ff7
commit d8a6fcf979

View File

@ -67,7 +67,7 @@ public class BackupUtil {
File backupDirectory = StorageUtil.getBackupDirectory(context);
File[] backups = backupDirectory.listFiles();
if (backups != null && backups.length > 5) {
if (backups != null && backups.length > 2) {
Arrays.sort(backups, (left, right) -> {
long leftTimestamp = getBackupTimestamp(left);
long rightTimestamp = getBackupTimestamp(right);
@ -79,7 +79,7 @@ public class BackupUtil {
return (int)(rightTimestamp - leftTimestamp);
});
for (int i=5;i<backups.length;i++) {
for (int i=2;i<backups.length;i++) {
Log.w(TAG, "Deleting: " + backups[i].getAbsolutePath());
if (!backups[i].delete()) {