Browse Source

Don't try to convert huge fonts to woff2, otherwise the server freezes for too long

Gaël Métais 4 năm trước cách đây
mục cha
commit
dd439d5ec3
1 tập tin đã thay đổi với 7 bổ sung1 xóa
  1. 7 1
      lib/tools/redownload/fontAnalyzer.js

+ 7 - 1
lib/tools/redownload/fontAnalyzer.js

@@ -55,6 +55,12 @@ var FontAnalyzer = function() {
             debug('File is already a woff2.');
             deferred.resolve(entry);
 
+        } else if (fileSize > 1024 * 1024) {
+
+            // Don't try to convert huge font files, it would block the server for several minutes
+            debug('Font is too big, skipping conversion.');
+            deferred.resolve(entry);
+
         } else if (entry.isWoff) {
 
             debug('File is a woff. Let\'s convert to woff2');
@@ -67,7 +73,7 @@ var FontAnalyzer = function() {
                 woff2 = ttf2woff2(ttf);
                 newFileSize = woff2.length;
 
-                debug('New image size is %d', newFileSize);
+                debug('New font size is %d', newFileSize);
                 debug('Filesize is %d bytes smaller (-%d%)', fileSize - newFileSize, Math.round((fileSize - newFileSize) * 100 / fileSize));
                 entry.weightCheck.sizeAsWoff2 = newFileSize;