Skip to content

Commit

Permalink
Added restriction such that only non-directory files can be compressed
Browse files Browse the repository at this point in the history
to xz format (due to xz specification). Updated maven plugins.
  • Loading branch information
dscalzi committed Mar 9, 2018
1 parent 41c3993 commit 868da65
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 136 deletions.
125 changes: 0 additions & 125 deletions dependency-reduced-pom.xml

This file was deleted.

11 changes: 7 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.dscalzi</groupId>
<artifactId>ZipExtractor</artifactId>
<version>1.2.1</version>
<version>1.2.0</version>
<name>Zip Extractor</name>
<description>Utility plugin to extract archives and compress files.</description>
<url>https://github.com/dscalzi/ZipExtractor</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -30,8 +31,9 @@
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -41,7 +43,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -50,7 +52,7 @@
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
<finalName>ZipExtractor</finalName>
<finalName>ZipExtractor-${version}</finalName>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
Expand Down Expand Up @@ -135,4 +137,5 @@
</exclusions>
</dependency>
</dependencies>

</project>
18 changes: 12 additions & 6 deletions src/main/java/com/dscalzi/zipextractor/providers/XZProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> SUPPORTED = new ArrayList<String>(Arrays.asList("xz"));
public static final List<String> SUPPORTED_EXTRACT = new ArrayList<String>(Arrays.asList("xz"));
public static final List<String> SUPPORTED_COMPRESS = new ArrayList<String>(Arrays.asList("non-directory"));

@Override
public List<String> scanForExtractionConflicts(CommandSender sender, File src, File dest) {
Expand All @@ -48,7 +49,7 @@ public List<String> 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(""));
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -107,12 +108,17 @@ public boolean destValidForCompression(File dest) {

@Override
public List<String> supportedExtractionTypes() {
return SUPPORTED;
return SUPPORTED_EXTRACT;
}

@Override
public List<String> canCompressTo() {
return SUPPORTED;
return SUPPORTED_EXTRACT;
}

@Override
public List<String> canCompressFrom() {
return SUPPORTED_COMPRESS;
}

}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 868da65

Please sign in to comment.