diff --git a/services/web/app/coffee/Features/Uploads/FileTypeManager.coffee b/services/web/app/coffee/Features/Uploads/FileTypeManager.coffee index 918f66df7b..524c6915e0 100644 --- a/services/web/app/coffee/Features/Uploads/FileTypeManager.coffee +++ b/services/web/app/coffee/Features/Uploads/FileTypeManager.coffee @@ -3,7 +3,7 @@ Path = require("path") module.exports = FileTypeManager = TEXT_EXTENSIONS : [ - "tex", "latex", "sty", "cls", "bst", "bib", "bibtex", "txt", "tikz", "rtex", "md", "asy" + "tex", "latex", "sty", "cls", "bst", "bib", "bibtex", "txt", "tikz", "rtex", "md", "asy", "latexmkrc" ] IGNORE_EXTENSIONS : [ @@ -34,7 +34,7 @@ module.exports = FileTypeManager = extension = parts.slice(-1)[0] if extension? extension = extension.toLowerCase() - binaryFile = (@TEXT_EXTENSIONS.indexOf(extension) == -1 or parts.length <= 1) + binaryFile = (@TEXT_EXTENSIONS.indexOf(extension) == -1 or parts.length <= 1) and parts[0] != 'latexmkrc' if binaryFile return callback null, true @@ -52,13 +52,10 @@ module.exports = FileTypeManager = if extension? extension = extension.toLowerCase() ignore = false - if name[0] == "." + if name[0] == "." and extension != 'latexmkrc' ignore = true if @IGNORE_EXTENSIONS.indexOf(extension) != -1 ignore = true if @IGNORE_FILENAMES.indexOf(name) != -1 ignore = true callback null, ignore - - - diff --git a/services/web/test/unit/coffee/Uploads/FileTypeManagerTests.coffee b/services/web/test/unit/coffee/Uploads/FileTypeManagerTests.coffee index c6fdf64829..be456c74a5 100644 --- a/services/web/test/unit/coffee/Uploads/FileTypeManagerTests.coffee +++ b/services/web/test/unit/coffee/Uploads/FileTypeManagerTests.coffee @@ -39,7 +39,7 @@ describe "FileTypeManager", -> beforeEach -> @stat = { size: 100 } @fs.stat = sinon.stub().callsArgWith(1, null, @stat) - + it "should return .tex files as not binary", -> @FileTypeManager.isBinary "file.tex", "/path/on/disk", (error, binary) -> binary.should.equal false @@ -80,10 +80,18 @@ describe "FileTypeManager", -> @FileTypeManager.isBinary "tex", "/path/on/disk", (error, binary) -> binary.should.equal true + it "should return .latexmkrc file as not binary", -> + @FileTypeManager.isBinary ".latexmkrc", "/path/on/disk", (error, binary) -> + binary.should.equal false + + it "should return latexmkrc file as not binary", -> + @FileTypeManager.isBinary "latexmkrc", "/path/on/disk", (error, binary) -> + binary.should.equal false + it "should ignore the case of an extension", -> @FileTypeManager.isBinary "file.TEX", "/path/on/disk", (error, binary) -> binary.should.equal false - + it "should return large text files as binary", -> @stat.size = 2 * 1024 * 1024 # 2Mb @FileTypeManager.isBinary "file.tex", "/path/on/disk", (error, binary) -> @@ -98,6 +106,10 @@ describe "FileTypeManager", -> @FileTypeManager.shouldIgnore "path/.git", (error, ignore) -> ignore.should.equal true + it "should not ignore .latexmkrc dotfile", -> + @FileTypeManager.shouldIgnore "path/.latexmkrc", (error, ignore) -> + ignore.should.equal false + it "should ignore __MACOSX", -> @FileTypeManager.shouldIgnore "path/__MACOSX", (error, ignore) -> ignore.should.equal true @@ -109,5 +121,3 @@ describe "FileTypeManager", -> it "should ignore the case of the extension", -> @FileTypeManager.shouldIgnore "file.AUX", (error, ignore) -> ignore.should.equal true - -