mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
Merge pull request #205 from Haafingar/fixbackups
Fix Backup Names & File Paths
This commit is contained in:
commit
163548328c
@ -65,13 +65,13 @@ public class LocalBackupJob extends BaseJob {
|
|||||||
GenericForegroundService.startForegroundTask(context,
|
GenericForegroundService.startForegroundTask(context,
|
||||||
context.getString(R.string.LocalBackupJob_creating_backup),
|
context.getString(R.string.LocalBackupJob_creating_backup),
|
||||||
NotificationChannels.BACKUPS,
|
NotificationChannels.BACKUPS,
|
||||||
R.drawable.ic_signal_backup);
|
R.drawable.ic_launcher_foreground);
|
||||||
|
// maybe create a new backup symbol like ic_signal_backup
|
||||||
try {
|
try {
|
||||||
String backupPassword = BackupPassphrase.get(context);
|
String backupPassword = BackupPassphrase.get(context);
|
||||||
File backupDirectory = StorageUtil.getBackupDirectory();
|
File backupDirectory = StorageUtil.getBackupDirectory();
|
||||||
String timestamp = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US).format(new Date());
|
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);
|
File backupFile = new File(backupDirectory, fileName);
|
||||||
|
|
||||||
if (backupFile.exists()) {
|
if (backupFile.exists()) {
|
||||||
|
@ -59,7 +59,7 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
|
|||||||
Context context = contextReference.get();
|
Context context = contextReference.get();
|
||||||
String directory = null;
|
String directory = null;
|
||||||
|
|
||||||
if (!StorageUtil.canWriteInSignalStorageDir()) {
|
if (!StorageUtil.canWriteInSessionStorageDir()) {
|
||||||
return new Pair<>(WRITE_ACCESS_FAILURE, null);
|
return new Pair<>(WRITE_ACCESS_FAILURE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
package org.thoughtcrime.securesms.util;
|
package org.thoughtcrime.securesms.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import com.annimon.stream.Objects;
|
|
||||||
import com.annimon.stream.Stream;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.database.NoExternalStorageException;
|
import org.thoughtcrime.securesms.database.NoExternalStorageException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -21,8 +17,8 @@ public class StorageUtil {
|
|||||||
throw new NoExternalStorageException();
|
throw new NoExternalStorageException();
|
||||||
}
|
}
|
||||||
|
|
||||||
File signal = new File(storage, "Signal");
|
File session = new File(storage, "Session");
|
||||||
File backups = new File(signal, "Backups");
|
File backups = new File(session, "Backups");
|
||||||
|
|
||||||
if (!backups.exists()) {
|
if (!backups.exists()) {
|
||||||
if (!backups.mkdirs()) {
|
if (!backups.mkdirs()) {
|
||||||
@ -37,7 +33,7 @@ public class StorageUtil {
|
|||||||
return context.getExternalCacheDir();
|
return context.getExternalCacheDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File getSignalStorageDir() throws NoExternalStorageException {
|
private static File getSessionStorageDir() throws NoExternalStorageException {
|
||||||
final File storage = Environment.getExternalStorageDirectory();
|
final File storage = Environment.getExternalStorageDirectory();
|
||||||
|
|
||||||
if (!storage.canWrite()) {
|
if (!storage.canWrite()) {
|
||||||
@ -47,11 +43,11 @@ public class StorageUtil {
|
|||||||
return storage;
|
return storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canWriteInSignalStorageDir() {
|
public static boolean canWriteInSessionStorageDir() {
|
||||||
File storage;
|
File storage;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
storage = getSignalStorageDir();
|
storage = getSessionStorageDir();
|
||||||
} catch (NoExternalStorageException e) {
|
} catch (NoExternalStorageException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -60,23 +56,23 @@ public class StorageUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static File getLegacyBackupDirectory() throws NoExternalStorageException {
|
public static File getLegacyBackupDirectory() throws NoExternalStorageException {
|
||||||
return getSignalStorageDir();
|
return getSessionStorageDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getVideoDir() throws NoExternalStorageException {
|
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 {
|
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 {
|
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 {
|
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) {
|
public static @Nullable String getCleanFileName(@Nullable String fileName) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user