Skip to content

Commit

Permalink
Merge branch 'release/0.4.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
micheljung committed Apr 12, 2017
2 parents fd4b3ac + 9d5627b commit 4a925c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ apply plugin: 'org.springframework.boot'
apply plugin: 'propdeps'

group = 'micheljung'
version = '0.4.7'
version = '0.4.8'

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private Optional<StagedFile> packDirectory(Path directory, Short version, Path t

createDirectories(targetFolder);
try (ZipArchiveOutputStream outputStream = new ZipArchiveOutputStream(tmpNxtFile.toFile())) {
zipContents(directory, outputStream);
zipDirectory(directory, outputStream);
}
return Optional.of(new StagedFile(fileId, tmpNxtFile, targetNxtFile, clientFileName));
}
Expand Down Expand Up @@ -233,10 +233,10 @@ private Path toTmpFile(Path targetFile) {
* this implementation uses Apache's commons compress which doesn't use data descriptors as long as the target is a
* file or a seekable byte channel.
*/
private void zipContents(Path directoryToZip, ZipArchiveOutputStream outputStream) throws IOException {
private void zipDirectory(Path directoryToZip, ZipArchiveOutputStream outputStream) throws IOException {
Files.walkFileTree(directoryToZip, new SimpleFileVisitor<Path>() {
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
String relativized = directoryToZip.relativize(dir).toString();
String relativized = directoryToZip.getParent().relativize(dir).toString();
if (!relativized.isEmpty()) {
outputStream.putArchiveEntry(new ZipArchiveEntry(relativized + "/"));
outputStream.closeArchiveEntry();
Expand All @@ -248,7 +248,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
log.trace("Zipping file {}", file.toAbsolutePath());
outputStream.putArchiveEntry(new ZipArchiveEntry(
file.toFile(),
directoryToZip.relativize(file).toString().replace(File.separatorChar, '/'))
directoryToZip.getParent().relativize(file).toString().replace(File.separatorChar, '/'))
);

try (InputStream inputStream = Files.newInputStream(file)) {
Expand Down

0 comments on commit 4a925c6

Please sign in to comment.