Skip to content

Commit

Permalink
SAK-43573 make compression level configurable (sakaiproject#8163)
Browse files Browse the repository at this point in the history
  • Loading branch information
ottenhoff authored Apr 21, 2020
1 parent 5d61813 commit 5a79be5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2937,6 +2937,7 @@ private void zipSubmissions(String assignmentReference, String assignmentTitle,

try {
out = new ZipOutputStream(outputStream);
out.setLevel(serverConfigurationService.getInt("zip.compression.level", 1));

// create the folder structure - named after the assignment's title
final String root = escapeInvalidCharsEntry(Validator.escapeZipEntry(assignmentTitle)) + Entity.SEPARATOR;
Expand Down Expand Up @@ -3233,6 +3234,7 @@ protected void zipGroupSubmissions(String assignmentReference, String assignment
ZipOutputStream out = null;
try {
out = new ZipOutputStream(outputStream);
out.setLevel(serverConfigurationService.getInt("zip.compression.level", 1));

// create the folder structure - named after the assignment's title
final String root = escapeInvalidCharsEntry(Validator.escapeZipEntry(assignmentTitle)) + Entity.SEPARATOR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,12 @@
# content.zip.expand.charsets.count=1
# content.zip.expand.charsets.1=GBK

# SAK-43573
# What compression level to use when creating ZIPs for instructor download
# Used in Samigo, Lessons, Assignments, Resources
# 0=no compression (fastest), 1=fastest compression (default), 6=best value, 9=highest compression (most cpu)
# zip.compression.level=6

# Enable creation of Web Content tools from resources, on by default.
# DEFAULT: true
# content.make.site.page=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public void compressFolder(Reference reference) {
temp = File.createTempFile("sakai_content-", ".tmp");
ContentCollection collection = ContentHostingService.getCollection(reference.getId());
out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(temp),BUFFER_SIZE),java.nio.charset.StandardCharsets.UTF_8);
out.setLevel(ServerConfigurationService.getInt("zip.compression.level", 1));
storeContentCollection(reference.getId(),collection,out);
} finally {
if (out != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,7 @@ public boolean download() {
try {
htmlOut = response.getOutputStream();
out = new ZipPrintStream(htmlOut);
out.setLevel(ServerConfigurationService.getInt("zip.compression.level", 1));

response.setHeader("Content-disposition", "inline; filename=sakai-export.imscc");
response.setContentType("application/zip");
Expand Down

0 comments on commit 5a79be5

Please sign in to comment.