diff --git a/src/main/java/org/qortal/arbitrary/ArbitraryDataReader.java b/src/main/java/org/qortal/arbitrary/ArbitraryDataReader.java index 9fd1581b..4261e715 100644 --- a/src/main/java/org/qortal/arbitrary/ArbitraryDataReader.java +++ b/src/main/java/org/qortal/arbitrary/ArbitraryDataReader.java @@ -358,10 +358,18 @@ public class ArbitraryDataReader { } try { - // TODO: compression types - //if (transactionData.getCompression() == ArbitraryTransactionData.Compression.ZIP) { + // Handle each type of compression + if (transactionData.getCompression() == Compression.ZIP) { ZipUtils.unzip(this.filePath.toString(), this.uncompressedPath.getParent().toString()); - //} + } + else if (transactionData.getCompression() == Compression.NONE) { + Files.createDirectories(this.uncompressedPath); + Path finalPath = Paths.get(this.uncompressedPath.toString(), "data"); + this.filePath.toFile().renameTo(finalPath.toFile()); + } + else { + throw new IllegalStateException(String.format("Unrecognized compression type: %s", transactionData.getCompression())); + } } catch (IOException e) { throw new IllegalStateException(String.format("Unable to unzip file: %s", e.getMessage())); } diff --git a/src/main/java/org/qortal/arbitrary/ArbitraryDataTransactionBuilder.java b/src/main/java/org/qortal/arbitrary/ArbitraryDataTransactionBuilder.java index b1e273fb..280fc5c9 100644 --- a/src/main/java/org/qortal/arbitrary/ArbitraryDataTransactionBuilder.java +++ b/src/main/java/org/qortal/arbitrary/ArbitraryDataTransactionBuilder.java @@ -65,7 +65,10 @@ public class ArbitraryDataTransactionBuilder { random.nextBytes(lastReference); } - ArbitraryTransactionData.Compression compression = ArbitraryTransactionData.Compression.ZIP; + Compression compression = Compression.ZIP; + + // FUTURE? Use zip compression for directories, or no compression for single files + // Compression compression = (path.toFile().isDirectory()) ? Compression.ZIP : Compression.NONE; ArbitraryDataWriter arbitraryDataWriter = new ArbitraryDataWriter(path, name, service, identifier, method, compression); try {