From 868da6505075f303d7281e53ad0ec3f29849cbf4 Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Thu, 8 Mar 2018 22:58:21 -0500 Subject: [PATCH] Added restriction such that only non-directory files can be compressed to xz format (due to xz specification). Updated maven plugins. --- dependency-reduced-pom.xml | 125 ------------------ pom.xml | 11 +- .../zipextractor/providers/XZProvider.java | 18 ++- src/main/resources/plugin.yml | 2 +- 4 files changed, 20 insertions(+), 136 deletions(-) delete mode 100644 dependency-reduced-pom.xml diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml deleted file mode 100644 index e05e0b4..0000000 --- a/dependency-reduced-pom.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - 4.0.0 - com.dscalzi - ZipExtractor - Zip Extractor - 1.2.1 - Utility plugin to extract archives and compress files. - - - Daniel Scalzi (TheKraken7) - - Project Lead - - - - - package - - - true - src/main/resources - - - ZipExtractor - - - maven-compiler-plugin - 3.5.1 - - 1.8 - 1.8 - - - - maven-shade-plugin - 2.4.3 - - - package - - shade - - - true - ZipExtractor - - - org.bstats - lib.org.bstats - - - - - com.github.junrar:junrar - - META-INF/** - - - - commons-logging:commons-logging-api - - org/apache/commons/logging/** - - - - - - - - - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - bstats-repo - http://repo.bstats.org/content/repositories/releases/ - - - - - org.spigotmc - spigot-api - 1.11.2-R0.1-SNAPSHOT - provided - - - commons-lang - commons-lang - - - json-simple - com.googlecode.json-simple - - - guava - com.google.guava - - - gson - com.google.code.gson - - - ebean - org.avaje - - - snakeyaml - org.yaml - - - bungeecord-chat - net.md-5 - - - - - - UTF-8 - - - diff --git a/pom.xml b/pom.xml index 4077b7b..9be21fd 100644 --- a/pom.xml +++ b/pom.xml @@ -2,9 +2,10 @@ 4.0.0 com.dscalzi ZipExtractor - 1.2.1 + 1.2.0 Zip Extractor Utility plugin to extract archives and compress files. + https://github.com/dscalzi/ZipExtractor UTF-8 @@ -30,8 +31,9 @@ + org.apache.maven.plugins maven-compiler-plugin - 3.5.1 + 3.7.0 1.8 1.8 @@ -41,7 +43,7 @@ org.apache.maven.plugins maven-shade-plugin - 2.4.3 + 3.1.0 package @@ -50,7 +52,7 @@ true - ZipExtractor + ZipExtractor-${version} org.bstats @@ -135,4 +137,5 @@ + \ No newline at end of file diff --git a/src/main/java/com/dscalzi/zipextractor/providers/XZProvider.java b/src/main/java/com/dscalzi/zipextractor/providers/XZProvider.java index 1f9a456..ba17748 100644 --- a/src/main/java/com/dscalzi/zipextractor/providers/XZProvider.java +++ b/src/main/java/com/dscalzi/zipextractor/providers/XZProvider.java @@ -30,7 +30,8 @@ public class XZProvider implements TypeProvider { //Shared pattern by ZipProviders public static final Pattern PATH_END = Pattern.compile("\\.xz$"); - public static final List SUPPORTED = new ArrayList(Arrays.asList("xz")); + public static final List SUPPORTED_EXTRACT = new ArrayList(Arrays.asList("xz")); + public static final List SUPPORTED_COMPRESS = new ArrayList(Arrays.asList("non-directory")); @Override public List scanForExtractionConflicts(CommandSender sender, File src, File dest) { @@ -48,7 +49,7 @@ public List scanForExtractionConflicts(CommandSender sender, File src, F public void extract(CommandSender sender, File src, File dest) { final ConfigManager cm = ConfigManager.getInstance(); final MessageManager mm = MessageManager.getInstance(); - final Logger logger = MessageManager.getInstance().getLogger(); + final Logger logger = mm.getLogger(); final boolean log = cm.getLoggingProperty(); mm.startingProcess(sender, ZTask.EXTRACT, src.getName()); File realDest = new File(dest.getAbsolutePath(), PATH_END.matcher(src.getName()).replaceAll("")); @@ -76,7 +77,7 @@ public void extract(CommandSender sender, File src, File dest) { public void compress(CommandSender sender, File src, File dest) { final ConfigManager cm = ConfigManager.getInstance(); final MessageManager mm = MessageManager.getInstance(); - final Logger logger = MessageManager.getInstance().getLogger(); + final Logger logger = mm.getLogger(); final boolean log = cm.getLoggingProperty(); mm.startingProcess(sender, ZTask.COMPRESS, src.getName()); try(FileOutputStream fos = new FileOutputStream(dest); @@ -97,7 +98,7 @@ public boolean validForExtraction(File src) { @Override public boolean srcValidForCompression(File src) { - return true; //Any source file can be compressed to .xz. + return !src.isDirectory(); } @Override @@ -107,12 +108,17 @@ public boolean destValidForCompression(File dest) { @Override public List supportedExtractionTypes() { - return SUPPORTED; + return SUPPORTED_EXTRACT; } @Override public List canCompressTo() { - return SUPPORTED; + return SUPPORTED_EXTRACT; + } + + @Override + public List canCompressFrom() { + return SUPPORTED_COMPRESS; } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 468c4c2..1203960 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,7 +2,7 @@ author: Daniel Scalzi description: Utility plugin to extract archives and compress files. main: com.dscalzi.zipextractor.ZipExtractor name: ZipExtractor -version: 1.2.1 +version: 1.2.0 commands: zipextractor: description: Accesses plugin commands.