mattia / pagure

Forked from pagure 2 years ago
Clone

1004568 Fix rendering empty files

Authored and Committed by pingou 5 years ago
    Fix rendering empty files
    
    The first if checks if we can encode the text, if we can then it's a file
    otherwise we treat it as binary.
    However, we were doing ``if file_content`` as the file_content variable
    is set when the encoding works.
    However, in the case of an empty file, we could encode it so we have
    a valid ``file_content`` variable which contains... an empty string.
    So it would fail the ``if file_content`` check.
    
    We fix this by simply changing the check to ``if file_content is not None``
    then we're sure the encoding worked and we do not care if the content
    is an empty string or not.
    
        
file modified
+3 -8
file modified
+2 -2