#1969 Fix rendering empty file
Merged 7 years ago by pingou. Opened 7 years ago by farhaan.
farhaan/pagure easy-fix  into  master

file modified
+8 -3
@@ -159,9 +159,14 @@ 

          {% endif %}

  

      {% if output_type=='file' %}

-         {% autoescape false %}

-         {{ content | format_loc }}

-         {% endautoescape %}

+         {% if content.size != 0 %}

+             {% autoescape false %}

+             {{ content | format_loc }}

+             {% endautoescape %}

+         {% else %}

+             <p> No content in the file </p>

+         {% endif %}

+ 

      {% elif output_type == 'markup' %}

          <div class="m-a-2">

          {% autoescape false %}

file modified
+2 -2
@@ -476,7 +476,6 @@ 

      """ Displays the content of a file or a tree for the specified repo.

      """

      repo = flask.g.repo

-     reponame = flask.g.reponame

      repo_obj = flask.g.repo_obj

  

      if repo_obj.is_empty:
@@ -512,7 +511,6 @@ 

      if not content:

          flask.abort(404, 'File not found')

  

-     encoding = None

      readme = None

      safe = False

      readme_ext = None
@@ -566,6 +564,8 @@ 

                          style=style,)

                  )

                  output_type = 'file'

+             else:

+                 output_type = 'file'

          else:

              output_type = 'binary'

      else:

Empty file rendering throws 500 with this fix
the file gets rendered saying no content in the file

Signed-off-by: Farhaan Bukhsh farhaan.bukhsh@gmail.com

Anyway we can add tests for this?

rebased

7 years ago

i will have to look into it.

Ok since I want to make a 2.13.1 release with this fix, I'm going to merge it as is and open a ticket (assigned to you) about the unit-tests :)

rebased

7 years ago

Pull-Request has been merged by pingou

7 years ago