refactor: deprecate temp methods which uses global temp dir
This commit is contained in:
@@ -37,6 +37,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.core.plugins.files.IJadxFilesGetter;
|
||||
import jadx.core.utils.exceptions.JadxRuntimeException;
|
||||
|
||||
public class FileUtils {
|
||||
@@ -205,6 +206,11 @@ public class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* Migrate to {@link IJadxFilesGetter} from jadx args to get temp dir
|
||||
*/
|
||||
@Deprecated
|
||||
public static Path createTempDir(String prefix) {
|
||||
try {
|
||||
Path dir = Files.createTempDirectory(tempRootDir, prefix);
|
||||
@@ -215,6 +221,11 @@ public class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* Migrate to {@link IJadxFilesGetter} from jadx args to get temp dir
|
||||
*/
|
||||
@Deprecated
|
||||
public static Path createTempFile(String suffix) {
|
||||
try {
|
||||
Path path = Files.createTempFile(tempRootDir, JADX_TMP_PREFIX, suffix);
|
||||
@@ -225,6 +236,11 @@ public class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* Prefer {@link IJadxFilesGetter} from jadx args to get temp dir
|
||||
*/
|
||||
@Deprecated
|
||||
public static Path createTempFileNoDelete(String suffix) {
|
||||
try {
|
||||
return Files.createTempFile(Files.createTempDirectory("jadx-persist"), "jadx-", suffix);
|
||||
@@ -233,6 +249,11 @@ public class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* Migrate to {@link IJadxFilesGetter} from jadx args to get temp dir
|
||||
*/
|
||||
@Deprecated
|
||||
public static Path createTempFileNonPrefixed(String fileName) {
|
||||
try {
|
||||
Path path = Files.createFile(tempRootDir.resolve(fileName));
|
||||
|
||||
@@ -112,14 +112,21 @@ public class JadxPluginsList {
|
||||
}
|
||||
|
||||
private JadxPluginListCache fetchBundle(Release release) {
|
||||
Asset listAsset = release.getAssets().get(0);
|
||||
Path tmpListFile = FileUtils.createTempFile("list.zip");
|
||||
PluginUtils.downloadFile(listAsset.getDownloadUrl(), tmpListFile);
|
||||
|
||||
JadxPluginListCache listCache = new JadxPluginListCache();
|
||||
listCache.setVersion(release.getName());
|
||||
listCache.setList(loadListBundle(tmpListFile));
|
||||
return listCache;
|
||||
try {
|
||||
Asset listAsset = release.getAssets().get(0);
|
||||
Path tmpListFile = Files.createTempFile("plugins-list", ".zip");
|
||||
try {
|
||||
PluginUtils.downloadFile(listAsset.getDownloadUrl(), tmpListFile);
|
||||
JadxPluginListCache listCache = new JadxPluginListCache();
|
||||
listCache.setVersion(release.getName());
|
||||
listCache.setList(loadListBundle(tmpListFile));
|
||||
return listCache;
|
||||
} finally {
|
||||
Files.deleteIfExists(tmpListFile);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to load plugin-list bundle for release:" + release.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<JadxPluginMetadata> loadListBundle(Path tmpListFile) {
|
||||
|
||||
@@ -25,7 +25,6 @@ import jadx.core.Jadx;
|
||||
import jadx.core.plugins.versions.VerifyRequiredVersion;
|
||||
import jadx.core.utils.StringUtils;
|
||||
import jadx.core.utils.exceptions.JadxRuntimeException;
|
||||
import jadx.core.utils.files.FileUtils;
|
||||
import jadx.plugins.tools.data.JadxInstalledPlugins;
|
||||
import jadx.plugins.tools.data.JadxPluginMetadata;
|
||||
import jadx.plugins.tools.data.JadxPluginUpdate;
|
||||
@@ -260,15 +259,19 @@ public class JadxPluginsTools {
|
||||
}
|
||||
|
||||
private void fillMetadata(JadxPluginMetadata metadata) {
|
||||
Path tmpJar;
|
||||
if (needDownload(metadata.getJar())) {
|
||||
tmpJar = FileUtils.createTempFile("plugin.jar");
|
||||
PluginUtils.downloadFile(metadata.getJar(), tmpJar);
|
||||
metadata.setJar(tmpJar.toAbsolutePath().toString());
|
||||
} else {
|
||||
tmpJar = Paths.get(metadata.getJar());
|
||||
try {
|
||||
Path tmpJar;
|
||||
if (needDownload(metadata.getJar())) {
|
||||
tmpJar = Files.createTempFile(metadata.getName(), "plugin.jar");
|
||||
PluginUtils.downloadFile(metadata.getJar(), tmpJar);
|
||||
metadata.setJar(tmpJar.toAbsolutePath().toString());
|
||||
} else {
|
||||
tmpJar = Paths.get(metadata.getJar());
|
||||
}
|
||||
fillMetadataFromJar(metadata, tmpJar);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to fill plugin metadata, plugin: " + metadata.getPluginId(), e);
|
||||
}
|
||||
fillMetadataFromJar(metadata, tmpJar);
|
||||
}
|
||||
|
||||
private void fillMetadataFromJar(JadxPluginMetadata metadata, Path jar) {
|
||||
|
||||
Reference in New Issue
Block a user