Updated dependencies

Renamed GenericTarCompressor -> LZMACompressor
This commit is contained in:
Szum123321 2020-06-30 15:52:32 +02:00
parent 3e17a64714
commit 92d2d3e2df
2 changed files with 16 additions and 12 deletions

View File

@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
minecraft_version=1.16.1
yarn_mappings=1.16.1+build.4
yarn_mappings=1.16.1+build.18
loader_version=0.8.8+build.202
#Fabric api
fabric_version=0.13.1+build.370-1.16
fabric_version=0.14.0+build.371-1.16
# Mod Properties
mod_version = 1.2.2-1.16.1
mod_version = 1.2.3-1.16.1
maven_group = net.szum123321
archives_base_name = textile_backup

View File

@ -5,22 +5,22 @@ import net.szum123321.textile_backup.TextileBackup;
import net.szum123321.textile_backup.core.Utilities;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.compressors.xz.XZCompressorOutputStream;
import org.apache.commons.compress.utils.IOUtils;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
public class GenericTarCompressor {
public static void createArchive(File in, File out, Class<? extends OutputStream> CompressorStreamClass, ServerCommandSource ctx, int coreLimit) {
Utilities.log("Starting compression...", ctx);
public class LZMACompressor {
public static void createArchive(File in, File out, ServerCommandSource ctx) {
Utilities.info("Starting compression...", ctx);
long start = System.nanoTime();
try (FileOutputStream outStream = new FileOutputStream(out);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outStream);
OutputStream compressorStream = CompressorStreamClass.getDeclaredConstructor(OutputStream.class).newInstance(bufferedOutputStream);// CompressorStreamClass.getConstructor().newInstance(bufferedOutputStream);
XZCompressorOutputStream compressorStream = new XZCompressorOutputStream(bufferedOutputStream);// CompressorStreamClass.getConstructor().newInstance(bufferedOutputStream);
TarArchiveOutputStream arc = new TarArchiveOutputStream(compressorStream)) {
arc.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
@ -44,17 +44,21 @@ public class GenericTarCompressor {
arc.closeArchiveEntry();
} catch (IOException e) {
TextileBackup.logger.error(e.getMessage());
TextileBackup.LOGGER.error("An exception occurred while trying to compress: " + path.getFileName(), e);
Utilities.sendError("Something went wrong while compressing files!", ctx);
}
});
arc.finish();
} catch (IOException | IllegalAccessException | NoSuchMethodException | InstantiationException | InvocationTargetException e) {
TextileBackup.logger.error(e.toString());
} catch (IOException e) {
TextileBackup.LOGGER.error("An exception occurred!", e);
Utilities.sendError("Something went wrong while compressing files!", ctx);
}
long end = System.nanoTime();
Utilities.log("Compression took: " + ((end - start) / 1000000000.0) + "s", ctx);
Utilities.info("Compression took: " + ((end - start) / 1000000000.0) + "s", ctx);
}
}