Skip to content

Commit

Permalink
fix: Add application/gzip to recognize gzipped files
Browse files Browse the repository at this point in the history
  • Loading branch information
loquisgon authored and fhussonnois committed Mar 9, 2023
1 parent c4b58d3 commit f49e75c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class GZipCodec implements CodecHandler {

static {
MIME_TYPES.add("application/x-gzip");
MIME_TYPES.add("application/gzip");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.stream.Collectors;
import java.util.zip.GZIPOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

Expand Down Expand Up @@ -77,6 +78,26 @@ public void shouldExtractXZGipCompressedFilesPathWhileScanningGivenRecursiveScan
Assert.assertEquals(expected, getCanonicalPath(scanned.iterator().next()));
}

@Test
public void shouldExtractGzipCompressedFiles() throws IOException {
File archiveFile = new File(inputDirectory, DEFAULT_ARCHIVE_NAME + ".gz");

try (GZIPOutputStream os = new GZIPOutputStream(new FileOutputStream(archiveFile))) {
byte[] data = "dummy".getBytes();
os.write(data, 0, data.length);
}

scanner.configure(new HashMap<>() {{
put(LocalFSDirectoryListingConfig.FS_LISTING_DIRECTORY_PATH, inputDirectory.getAbsolutePath());
}});

final Collection<FileObjectMeta> scanned = scanner.listObjects();
Assert.assertEquals(1, scanned.size());
String expected = String.join(File.separator, Arrays.asList(inputDirectory.getCanonicalPath(),
DEFAULT_ARCHIVE_NAME, DEFAULT_ARCHIVE_NAME));
Assert.assertEquals(expected, getCanonicalPath(scanned.iterator().next()));
}

@Test
public void shouldListFilesGivenRecursiveScanEnable() throws IOException {
folder.newFolder(TEST_SCAN_DIRECTORY , "sub-directory");
Expand Down

0 comments on commit f49e75c

Please sign in to comment.