mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 10:45:23 +08:00
Use FileUtils for clearing TMPDIR and move clearing function to ShellUtils from TermuxService
This commit is contained in:
@@ -154,17 +154,8 @@ public final class TermuxService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
Logger.logVerbose(LOG_TAG, "onDestroy");
|
Logger.logVerbose(LOG_TAG, "onDestroy");
|
||||||
File termuxTmpDir = TermuxConstants.TERMUX_TMP_DIR;
|
|
||||||
|
|
||||||
if (termuxTmpDir.exists()) {
|
ShellUtils.clearTermuxTMPDIR(this);
|
||||||
try {
|
|
||||||
TermuxInstaller.deleteDirectory(termuxTmpDir.getCanonicalFile());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.logStackTraceWithMessage(LOG_TAG, "Error while removing file at " + termuxTmpDir.getAbsolutePath(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
termuxTmpDir.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
actionReleaseWakeLock(false);
|
actionReleaseWakeLock(false);
|
||||||
finishAllTermuxSessions();
|
finishAllTermuxSessions();
|
||||||
|
@@ -3,6 +3,8 @@ package com.termux.app.shell;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import com.termux.app.TermuxConstants;
|
import com.termux.app.TermuxConstants;
|
||||||
|
import com.termux.app.file.FileUtils;
|
||||||
|
import com.termux.app.utils.Logger;
|
||||||
import com.termux.app.utils.PackageUtils;
|
import com.termux.app.utils.PackageUtils;
|
||||||
import com.termux.app.utils.TermuxUtils;
|
import com.termux.app.utils.TermuxUtils;
|
||||||
|
|
||||||
@@ -143,4 +145,12 @@ public class ShellUtils {
|
|||||||
return (lastSlash == -1) ? executable : executable.substring(lastSlash + 1);
|
return (lastSlash == -1) ? executable : executable.substring(lastSlash + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clearTermuxTMPDIR(Context context) {
|
||||||
|
String errmsg;
|
||||||
|
errmsg = FileUtils.clearDirectory(context, "$TMPDIR", FileUtils.getCanonicalPath(TermuxConstants.TERMUX_TMP_PREFIX_DIR_PATH, null, false));
|
||||||
|
if (errmsg != null) {
|
||||||
|
Logger.logErrorAndShowToast(context, errmsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user