mirror of
https://gitee.com/dcren/initializr.git
synced 2026-02-25 21:22:58 +08:00
Add support for long fine names for tar archives
See gh-1139
This commit is contained in:
committed by
Stephane Nicoll
parent
d878e89abc
commit
249b260774
@@ -141,7 +141,9 @@ public abstract class ProjectGenerationController<R extends ProjectRequest> {
|
||||
|
||||
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);
|
||||
|
||||
@@ -65,6 +65,15 @@ class ProjectGenerationControllerIntegrationTests extends AbstractInitializrCont
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user