Merge pull request #205 from Haafingar/fixbackups

Fix Backup Names & File Paths
This commit is contained in:
Niels Andriesse 2020-05-29 14:07:14 +10:00 committed by GitHub
commit 163548328c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 18 deletions

View File

@ -65,13 +65,13 @@ public class LocalBackupJob extends BaseJob {
GenericForegroundService.startForegroundTask(context,
context.getString(R.string.LocalBackupJob_creating_backup),
NotificationChannels.BACKUPS,
R.drawable.ic_signal_backup);
R.drawable.ic_launcher_foreground);
// maybe create a new backup symbol like ic_signal_backup
try {
String backupPassword = BackupPassphrase.get(context);
File backupDirectory = StorageUtil.getBackupDirectory();
String timestamp = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US).format(new Date());
String fileName = String.format("signal-%s.backup", timestamp);
String fileName = String.format("session-%s.backup", timestamp);
File backupFile = new File(backupDirectory, fileName);
if (backupFile.exists()) {

View File

@ -59,7 +59,7 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
Context context = contextReference.get();
String directory = null;
if (!StorageUtil.canWriteInSignalStorageDir()) {
if (!StorageUtil.canWriteInSessionStorageDir()) {
return new Pair<>(WRITE_ACCESS_FAILURE, null);
}

View File

@ -1,13 +1,9 @@
package org.thoughtcrime.securesms.util;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import android.support.annotation.Nullable;
import com.annimon.stream.Objects;
import com.annimon.stream.Stream;
import org.thoughtcrime.securesms.database.NoExternalStorageException;
import java.io.File;
@ -21,8 +17,8 @@ public class StorageUtil {
throw new NoExternalStorageException();
}
File signal = new File(storage, "Signal");
File backups = new File(signal, "Backups");
File session = new File(storage, "Session");
File backups = new File(session, "Backups");
if (!backups.exists()) {
if (!backups.mkdirs()) {
@ -37,7 +33,7 @@ public class StorageUtil {
return context.getExternalCacheDir();
}
private static File getSignalStorageDir() throws NoExternalStorageException {
private static File getSessionStorageDir() throws NoExternalStorageException {
final File storage = Environment.getExternalStorageDirectory();
if (!storage.canWrite()) {
@ -47,11 +43,11 @@ public class StorageUtil {
return storage;
}
public static boolean canWriteInSignalStorageDir() {
public static boolean canWriteInSessionStorageDir() {
File storage;
try {
storage = getSignalStorageDir();
storage = getSessionStorageDir();
} catch (NoExternalStorageException e) {
return false;
}
@ -60,23 +56,23 @@ public class StorageUtil {
}
public static File getLegacyBackupDirectory() throws NoExternalStorageException {
return getSignalStorageDir();
return getSessionStorageDir();
}
public static File getVideoDir() throws NoExternalStorageException {
return new File(getSignalStorageDir(), Environment.DIRECTORY_MOVIES);
return new File(getSessionStorageDir(), Environment.DIRECTORY_MOVIES);
}
public static File getAudioDir() throws NoExternalStorageException {
return new File(getSignalStorageDir(), Environment.DIRECTORY_MUSIC);
return new File(getSessionStorageDir(), Environment.DIRECTORY_MUSIC);
}
public static File getImageDir() throws NoExternalStorageException {
return new File(getSignalStorageDir(), Environment.DIRECTORY_PICTURES);
return new File(getSessionStorageDir(), Environment.DIRECTORY_PICTURES);
}
public static File getDownloadDir() throws NoExternalStorageException {
return new File(getSignalStorageDir(), Environment.DIRECTORY_DOWNLOADS);
return new File(getSessionStorageDir(), Environment.DIRECTORY_DOWNLOADS);
}
public static @Nullable String getCleanFileName(@Nullable String fileName) {