Skip to content

Commit

Permalink
GH-1121 Add POSIX config for long file name support for tar archives
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Theriault committed Oct 13, 2020
1 parent 314586d commit 14ff055
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ public ResponseEntity<byte[]> springTgz(R request) throws IOException {

private TarArchiveOutputStream createTarArchiveOutputStream(OutputStream output) {
try {
return new TarArchiveOutputStream(new GzipCompressorOutputStream(output));
final TarArchiveOutputStream taos = new TarArchiveOutputStream(new GzipCompressorOutputStream(output));
taos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
return taos;
}
catch (IOException ex) {
throw new IllegalStateException(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ void simpleTgzProject() {
assertThat(project).mavenBuild().hasDependenciesSize(2).hasDependency("org.acme", "foo", "1.3.5");
}

@Test
void tgzProjectWithLongFilenames() {
String queryParams = "name=spring-boot-service&dependencies=org.acme:foo&artifactId=spring-boot-service"
+ "&groupId=com.spring.boot.service&baseDir=spring-boot-service";

ResponseEntity<byte[]> entity = downloadArchive("/starter.tgz?" + queryParams);
assertArchiveResponseHeaders(entity, MediaType.valueOf("application/x-compress"), "spring-boot-service.tar.gz");
}

private void assertArchiveResponseHeaders(ResponseEntity<byte[]> entity, MediaType contentType, String fileName) {
assertThat(entity.getHeaders().getContentType()).isEqualTo(contentType);
assertThat(entity.getHeaders().getContentDisposition()).isNotNull();
Expand Down

0 comments on commit 14ff055

Please sign in to comment.