Remove pointless caching, saves ~40MB for flash memory

This commit is contained in:
Boulay Mathias 2022-07-22 22:10:11 +02:00
parent 34736cb702
commit e06c35bec4

View File

@ -77,16 +77,11 @@ public class MultiRTUtils {
public static void installRuntimeNamed(String nativeLibDir, InputStream runtimeInputStream, String name, RuntimeProgressReporter progressReporter) throws IOException { public static void installRuntimeNamed(String nativeLibDir, InputStream runtimeInputStream, String name, RuntimeProgressReporter progressReporter) throws IOException {
File dest = new File(RUNTIME_FOLDER,"/"+name); File dest = new File(RUNTIME_FOLDER,"/"+name);
File tmp = new File(dest,"temporary");
if(dest.exists()) FileUtils.deleteDirectory(dest); if(dest.exists()) FileUtils.deleteDirectory(dest);
dest.mkdirs(); dest.mkdirs();
FileOutputStream fos = new FileOutputStream(tmp);
progressReporter.reportStringProgress(R.string.multirt_progress_caching); uncompressTarXZ(runtimeInputStream,dest,progressReporter);
IOUtils.copy(runtimeInputStream,fos);
fos.close();
runtimeInputStream.close(); runtimeInputStream.close();
uncompressTarXZ(tmp,dest,progressReporter);
tmp.delete();
unpack200(nativeLibDir,RUNTIME_FOLDER + "/" + name); unpack200(nativeLibDir,RUNTIME_FOLDER + "/" + name);
read(name); read(name);
} }
@ -230,25 +225,16 @@ public class MultiRTUtils {
} }
private static void installRuntimeNamedNoRemove(InputStream runtimeInputStream, File dest, RuntimeProgressReporter progressReporter) throws IOException { private static void installRuntimeNamedNoRemove(InputStream runtimeInputStream, File dest, RuntimeProgressReporter progressReporter) throws IOException {
File tmp = new File(dest,"temporary");
FileOutputStream fos = new FileOutputStream(tmp); uncompressTarXZ(runtimeInputStream,dest,progressReporter);
progressReporter.reportStringProgress(R.string.multirt_progress_caching);
IOUtils.copy(runtimeInputStream,fos);
fos.close();
runtimeInputStream.close(); runtimeInputStream.close();
uncompressTarXZ(tmp,dest,progressReporter);
tmp.delete();
} }
private static void uncompressTarXZ(final File tarFile, final File dest, final RuntimeProgressReporter thingy) throws IOException { private static void uncompressTarXZ(final InputStream tarFileInputStream, final File dest, final RuntimeProgressReporter thingy) throws IOException {
dest.mkdirs(); dest.mkdirs();
TarArchiveInputStream tarIn = new TarArchiveInputStream( TarArchiveInputStream tarIn = new TarArchiveInputStream(
new XZCompressorInputStream( new XZCompressorInputStream(tarFileInputStream)
new BufferedInputStream(
new FileInputStream(tarFile)
)
)
); );
TarArchiveEntry tarEntry = tarIn.getNextTarEntry(); TarArchiveEntry tarEntry = tarIn.getNextTarEntry();
// tarIn is a TarArchiveInputStream // tarIn is a TarArchiveInputStream