[tor-commits] [orbot/master] delete files from storage
n8fr8 at torproject.org
n8fr8 at torproject.org
Thu Mar 2 04:10:21 UTC 2017
commit f76f58e2bf75ce04326a55659731c332360eb835
Author: arrase <arrase at gmail.com>
Date: Mon Nov 28 23:43:43 2016 +0100
delete files from storage
---
.../ui/hiddenservices/dialogs/HSDeleteDialog.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java
index 4e0643e..ac5df74 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java
@@ -10,8 +10,11 @@ import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import org.torproject.android.R;
+import org.torproject.android.service.TorServiceConstants;
import org.torproject.android.ui.hiddenservices.providers.HSContentProvider;
+import java.io.File;
+
public class HSDeleteDialog extends DialogFragment {
@NonNull
@@ -25,11 +28,25 @@ public class HSDeleteDialog extends DialogFragment {
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
+ // Delete from db
context.getContentResolver().delete(
HSContentProvider.CONTENT_URI,
HSContentProvider.HiddenService._ID + "=" + arguments.getInt("_id"),
null
);
+
+ // Delete from interal storage
+ String base = context.getFilesDir().getAbsolutePath() + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR;
+ File dir = new File(base, "hs" + arguments.getString("port"));
+
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (String aChildren : children) {
+ new File(dir, aChildren).delete();
+ }
+ dir.delete();
+ }
+
break;
case DialogInterface.BUTTON_NEGATIVE:
More information about the tor-commits
mailing list