bug fix and refactor

This commit is contained in:
arrase 2016-11-23 21:20:50 +01:00
parent 0b21dfc46a
commit f79d2d9005
3 changed files with 9 additions and 9 deletions

View File

@ -649,14 +649,14 @@ public class OrbotMainActivity extends AppCompatActivity
BackupUtils hsutils = new BackupUtils(getApplicationContext());
if(keyZipPath != null && keyZipPath.length() > 0)
{
hsutils.restoreOnionBackup(hsPort, keyZipPath);
hsutils.restoreZipBackup(hsPort, keyZipPath);
requestTorRereadConfig();
}
/* TODO
if(doBackup)
{
backupPath = hsutils.createOnionBackup(hsPort);
backupPath = hsutils.createZipBackup(hsPort);
}
*/
onion.close();

View File

@ -9,16 +9,16 @@ import org.torproject.android.storage.ExternalStorage;
import java.io.File;
public class BackupUtils {
private static File mHSBasePath;
private File mHSBasePath;
public BackupUtils(Context context) {
mHSBasePath = context.getDir(
TorServiceConstants.DIRECTORY_TOR_DATA + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR,
TorServiceConstants.DIRECTORY_TOR_DATA,
Application.MODE_PRIVATE
);
}
public String createOnionBackup(Integer port) {
public String createZipBackup(Integer port) {
ExternalStorage storage = new ExternalStorage();
String storage_path = storage.createBackupDir();
@ -28,8 +28,8 @@ public class BackupUtils {
String zip_path = storage_path + "/hs" + port + ".zip";
String files[] = {
mHSBasePath + "/hs" + port + "/hostname",
mHSBasePath + "/hs" + port + "/private_key"
mHSBasePath + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR + "/hs" + port + "/hostname",
mHSBasePath + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR + "/hs" + port + "/private_key"
};
ZipIt zip = new ZipIt(files, zip_path);
@ -41,7 +41,7 @@ public class BackupUtils {
return zip_path;
}
public void restoreOnionBackup(Integer port, String path) {
public void restoreZipBackup(Integer port, String path) {
ZipIt zip = new ZipIt(null, path);
zip.unzip(mHSBasePath + "/hs" + port);
}

View File

@ -50,7 +50,7 @@ public class HSActionsDialog extends DialogFragment {
}
BackupUtils hsutils = new BackupUtils(mContext);
String backupPath = hsutils.createOnionBackup(Integer.parseInt(arguments.getString("port")));
String backupPath = hsutils.createZipBackup(Integer.parseInt(arguments.getString("port")));
if (backupPath == null || backupPath.length() < 1) {
Toast.makeText(mContext, R.string.error, Toast.LENGTH_LONG).show();