We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
File download is outdated
### Steps to reproduce
1. Edit string.
2. Donwload original translation file (without conversion).

### Actual behaviour
The file does not have recent changes.

### Expected behaviour
All changes should be reflected.

### Server configuration
Current master


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `weblate/trans/views/helper.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright © 2012 - 2017 Michal Čihař <michal@cihar.com>
4 #
5 # This file is part of Weblate <https://weblate.org/>
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
19 #
20 """Helper methods for views."""
21 
22 from django.http import HttpResponse, Http404
23 from django.shortcuts import get_object_or_404
24 import django.utils.translation
25 from django.utils.translation import trans_real, ugettext as _
26 
27 from weblate.utils import messages
28 from weblate.permissions.helpers import check_access
29 from weblate.trans.exporters import get_exporter
30 from weblate.trans.models import Project, SubProject, Translation
31 
32 
33 def get_translation(request, project, subproject, lang, skip_acl=False):
34     """Return translation matching parameters."""
35     translation = get_object_or_404(
36         Translation.objects.prefetch(),
37         language__code=lang,
38         subproject__slug=subproject,
39         subproject__project__slug=project,
40         enabled=True
41     )
42     if not skip_acl:
43         check_access(request, translation.subproject.project)
44     return translation
45 
46 
47 def get_subproject(request, project, subproject, skip_acl=False):
48     """Return subproject matching parameters."""
49     subproject = get_object_or_404(
50         SubProject.objects.prefetch(),
51         project__slug=project,
52         slug=subproject
53     )
54     if not skip_acl:
55         check_access(request, subproject.project)
56     return subproject
57 
58 
59 def get_project(request, project, skip_acl=False):
60     """Return project matching parameters."""
61     project = get_object_or_404(
62         Project,
63         slug=project,
64     )
65     if not skip_acl:
66         check_access(request, project)
67     return project
68 
69 
70 def get_project_translation(request, project=None, subproject=None, lang=None):
71     """Return project, subproject, translation tuple for given parameters."""
72 
73     if lang is not None and subproject is not None:
74         # Language defined? We can get all
75         translation = get_translation(request, project, subproject, lang)
76         subproject = translation.subproject
77         project = subproject.project
78     else:
79         translation = None
80         if subproject is not None:
81             # Component defined?
82             subproject = get_subproject(request, project, subproject)
83             project = subproject.project
84         elif project is not None:
85             # Only project defined?
86             project = get_project(request, project)
87 
88     # Return tuple
89     return project, subproject, translation
90 
91 
92 def try_set_language(lang):
93     """Try to activate language"""
94 
95     try:
96         django.utils.translation.activate(lang)
97         # workaround for https://code.djangoproject.com/ticket/26050
98         # pylint: disable=W0212
99         if trans_real.catalog()._catalog is None:
100             raise Exception('Invalid language!')
101     except Exception:
102         # Ignore failure on activating language
103         django.utils.translation.activate('en')
104 
105 
106 def import_message(request, count, message_none, message_ok):
107     if count == 0:
108         messages.warning(request, message_none)
109     else:
110         messages.success(request, message_ok % count)
111 
112 
113 def download_translation_file(translation, fmt=None):
114     if fmt is not None:
115         try:
116             exporter = get_exporter(fmt)(translation=translation)
117         except KeyError:
118             raise Http404('File format not supported')
119         exporter.add_units(translation)
120         return exporter.get_response(
121             '{{project}}-{0}-{{language}}.{{extension}}'.format(
122                 translation.subproject.slug
123             )
124         )
125 
126     srcfilename = translation.get_filename()
127 
128     # Construct file name (do not use real filename as it is usually not
129     # that useful)
130     filename = '{0}-{1}-{2}.{3}'.format(
131         translation.subproject.project.slug,
132         translation.subproject.slug,
133         translation.language.code,
134         translation.store.extension
135     )
136 
137     # Create response
138     with open(srcfilename) as handle:
139         response = HttpResponse(
140             handle.read(),
141             content_type=translation.store.mimetype
142         )
143 
144     # Fill in response headers
145     response['Content-Disposition'] = 'attachment; filename={0}'.format(
146         filename
147     )
148 
149     return response
150 
151 
152 def show_form_errors(request, form):
153     """Show all form errors as a message."""
154     for error in form.non_field_errors():
155         messages.error(request, error)
156     for field in form:
157         for error in field.errors:
158             messages.error(
159                 request,
160                 _('Error in parameter %(field)s: %(error)s') % {
161                     'field': field.name,
162                     'error': error
163                 }
164             )
165
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/weblate/trans/views/helper.py b/weblate/trans/views/helper.py
--- a/weblate/trans/views/helper.py
+++ b/weblate/trans/views/helper.py
@@ -123,6 +123,10 @@
             )
         )
 
+    # Force flushing pending units
+    author = translation.get_last_author(True)
+    translation.update_units(author)
+
     srcfilename = translation.get_filename()
 
     # Construct file name (do not use real filename as it is usually not

{"golden_diff": "diff --git a/weblate/trans/views/helper.py b/weblate/trans/views/helper.py\n--- a/weblate/trans/views/helper.py\n+++ b/weblate/trans/views/helper.py\n@@ -123,6 +123,10 @@\n             )\n         )\n \n+    # Force flushing pending units\n+    author = translation.get_last_author(True)\n+    translation.update_units(author)\n+\n     srcfilename = translation.get_filename()\n \n     # Construct file name (do not use real filename as it is usually not\n", "issue": "File download is outdated\n### Steps to reproduce\r\n1. Edit string.\r\n2. Donwload original translation file (without conversion).\r\n\r\n### Actual behaviour\r\nThe file does not have recent changes.\r\n\r\n### Expected behaviour\r\nAll changes should be reflected.\r\n\r\n### Server configuration\r\nCurrent master\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright \u00a9 2012 - 2017 Michal \u010ciha\u0159 <michal@cihar.com>\n#\n# This file is part of Weblate <https://weblate.org/>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program.  If not, see <https://www.gnu.org/licenses/>.\n#\n\"\"\"Helper methods for views.\"\"\"\n\nfrom django.http import HttpResponse, Http404\nfrom django.shortcuts import get_object_or_404\nimport django.utils.translation\nfrom django.utils.translation import trans_real, ugettext as _\n\nfrom weblate.utils import messages\nfrom weblate.permissions.helpers import check_access\nfrom weblate.trans.exporters import get_exporter\nfrom weblate.trans.models import Project, SubProject, Translation\n\n\ndef get_translation(request, project, subproject, lang, skip_acl=False):\n    \"\"\"Return translation matching parameters.\"\"\"\n    translation = get_object_or_404(\n        Translation.objects.prefetch(),\n        language__code=lang,\n        subproject__slug=subproject,\n        subproject__project__slug=project,\n        enabled=True\n    )\n    if not skip_acl:\n        check_access(request, translation.subproject.project)\n    return translation\n\n\ndef get_subproject(request, project, subproject, skip_acl=False):\n    \"\"\"Return subproject matching parameters.\"\"\"\n    subproject = get_object_or_404(\n        SubProject.objects.prefetch(),\n        project__slug=project,\n        slug=subproject\n    )\n    if not skip_acl:\n        check_access(request, subproject.project)\n    return subproject\n\n\ndef get_project(request, project, skip_acl=False):\n    \"\"\"Return project matching parameters.\"\"\"\n    project = get_object_or_404(\n        Project,\n        slug=project,\n    )\n    if not skip_acl:\n        check_access(request, project)\n    return project\n\n\ndef get_project_translation(request, project=None, subproject=None, lang=None):\n    \"\"\"Return project, subproject, translation tuple for given parameters.\"\"\"\n\n    if lang is not None and subproject is not None:\n        # Language defined? We can get all\n        translation = get_translation(request, project, subproject, lang)\n        subproject = translation.subproject\n        project = subproject.project\n    else:\n        translation = None\n        if subproject is not None:\n            # Component defined?\n            subproject = get_subproject(request, project, subproject)\n            project = subproject.project\n        elif project is not None:\n            # Only project defined?\n            project = get_project(request, project)\n\n    # Return tuple\n    return project, subproject, translation\n\n\ndef try_set_language(lang):\n    \"\"\"Try to activate language\"\"\"\n\n    try:\n        django.utils.translation.activate(lang)\n        # workaround for https://code.djangoproject.com/ticket/26050\n        # pylint: disable=W0212\n        if trans_real.catalog()._catalog is None:\n            raise Exception('Invalid language!')\n    except Exception:\n        # Ignore failure on activating language\n        django.utils.translation.activate('en')\n\n\ndef import_message(request, count, message_none, message_ok):\n    if count == 0:\n        messages.warning(request, message_none)\n    else:\n        messages.success(request, message_ok % count)\n\n\ndef download_translation_file(translation, fmt=None):\n    if fmt is not None:\n        try:\n            exporter = get_exporter(fmt)(translation=translation)\n        except KeyError:\n            raise Http404('File format not supported')\n        exporter.add_units(translation)\n        return exporter.get_response(\n            '{{project}}-{0}-{{language}}.{{extension}}'.format(\n                translation.subproject.slug\n            )\n        )\n\n    srcfilename = translation.get_filename()\n\n    # Construct file name (do not use real filename as it is usually not\n    # that useful)\n    filename = '{0}-{1}-{2}.{3}'.format(\n        translation.subproject.project.slug,\n        translation.subproject.slug,\n        translation.language.code,\n        translation.store.extension\n    )\n\n    # Create response\n    with open(srcfilename) as handle:\n        response = HttpResponse(\n            handle.read(),\n            content_type=translation.store.mimetype\n        )\n\n    # Fill in response headers\n    response['Content-Disposition'] = 'attachment; filename={0}'.format(\n        filename\n    )\n\n    return response\n\n\ndef show_form_errors(request, form):\n    \"\"\"Show all form errors as a message.\"\"\"\n    for error in form.non_field_errors():\n        messages.error(request, error)\n    for field in form:\n        for error in field.errors:\n            messages.error(\n                request,\n                _('Error in parameter %(field)s: %(error)s') % {\n                    'field': field.name,\n                    'error': error\n                }\n            )\n", "path": "weblate/trans/views/helper.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright \u00a9 2012 - 2017 Michal \u010ciha\u0159 <michal@cihar.com>\n#\n# This file is part of Weblate <https://weblate.org/>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program.  If not, see <https://www.gnu.org/licenses/>.\n#\n\"\"\"Helper methods for views.\"\"\"\n\nfrom django.http import HttpResponse, Http404\nfrom django.shortcuts import get_object_or_404\nimport django.utils.translation\nfrom django.utils.translation import trans_real, ugettext as _\n\nfrom weblate.utils import messages\nfrom weblate.permissions.helpers import check_access\nfrom weblate.trans.exporters import get_exporter\nfrom weblate.trans.models import Project, SubProject, Translation\n\n\ndef get_translation(request, project, subproject, lang, skip_acl=False):\n    \"\"\"Return translation matching parameters.\"\"\"\n    translation = get_object_or_404(\n        Translation.objects.prefetch(),\n        language__code=lang,\n        subproject__slug=subproject,\n        subproject__project__slug=project,\n        enabled=True\n    )\n    if not skip_acl:\n        check_access(request, translation.subproject.project)\n    return translation\n\n\ndef get_subproject(request, project, subproject, skip_acl=False):\n    \"\"\"Return subproject matching parameters.\"\"\"\n    subproject = get_object_or_404(\n        SubProject.objects.prefetch(),\n        project__slug=project,\n        slug=subproject\n    )\n    if not skip_acl:\n        check_access(request, subproject.project)\n    return subproject\n\n\ndef get_project(request, project, skip_acl=False):\n    \"\"\"Return project matching parameters.\"\"\"\n    project = get_object_or_404(\n        Project,\n        slug=project,\n    )\n    if not skip_acl:\n        check_access(request, project)\n    return project\n\n\ndef get_project_translation(request, project=None, subproject=None, lang=None):\n    \"\"\"Return project, subproject, translation tuple for given parameters.\"\"\"\n\n    if lang is not None and subproject is not None:\n        # Language defined? We can get all\n        translation = get_translation(request, project, subproject, lang)\n        subproject = translation.subproject\n        project = subproject.project\n    else:\n        translation = None\n        if subproject is not None:\n            # Component defined?\n            subproject = get_subproject(request, project, subproject)\n            project = subproject.project\n        elif project is not None:\n            # Only project defined?\n            project = get_project(request, project)\n\n    # Return tuple\n    return project, subproject, translation\n\n\ndef try_set_language(lang):\n    \"\"\"Try to activate language\"\"\"\n\n    try:\n        django.utils.translation.activate(lang)\n        # workaround for https://code.djangoproject.com/ticket/26050\n        # pylint: disable=W0212\n        if trans_real.catalog()._catalog is None:\n            raise Exception('Invalid language!')\n    except Exception:\n        # Ignore failure on activating language\n        django.utils.translation.activate('en')\n\n\ndef import_message(request, count, message_none, message_ok):\n    if count == 0:\n        messages.warning(request, message_none)\n    else:\n        messages.success(request, message_ok % count)\n\n\ndef download_translation_file(translation, fmt=None):\n    if fmt is not None:\n        try:\n            exporter = get_exporter(fmt)(translation=translation)\n        except KeyError:\n            raise Http404('File format not supported')\n        exporter.add_units(translation)\n        return exporter.get_response(\n            '{{project}}-{0}-{{language}}.{{extension}}'.format(\n                translation.subproject.slug\n            )\n        )\n\n    # Force flushing pending units\n    author = translation.get_last_author(True)\n    translation.update_units(author)\n\n    srcfilename = translation.get_filename()\n\n    # Construct file name (do not use real filename as it is usually not\n    # that useful)\n    filename = '{0}-{1}-{2}.{3}'.format(\n        translation.subproject.project.slug,\n        translation.subproject.slug,\n        translation.language.code,\n        translation.store.extension\n    )\n\n    # Create response\n    with open(srcfilename) as handle:\n        response = HttpResponse(\n            handle.read(),\n            content_type=translation.store.mimetype\n        )\n\n    # Fill in response headers\n    response['Content-Disposition'] = 'attachment; filename={0}'.format(\n        filename\n    )\n\n    return response\n\n\ndef show_form_errors(request, form):\n    \"\"\"Show all form errors as a message.\"\"\"\n    for error in form.non_field_errors():\n        messages.error(request, error)\n    for field in form:\n        for error in field.errors:\n            messages.error(\n                request,\n                _('Error in parameter %(field)s: %(error)s') % {\n                    'field': field.name,\n                    'error': error\n                }\n            )\n", "path": "weblate/trans/views/helper.py"}]}