open-download: make sure the name is not too long

Fixes #1725.

Make sure that the temporary filename is not too long by restricting the
suggested part to 20 characters.
This commit is contained in:
Daniel Schadt 2016-08-02 00:57:22 +02:00
parent 9973cd5037
commit abcdaa9cce

View File

@ -1322,6 +1322,9 @@ class TempDownloadManager(QObject):
A tempfile.NamedTemporaryFile that should be used to save the file.
"""
tmpdir = self._get_tmpdir()
# Make sure that the filename is not too long
if len(suggested_name) > 20:
suggested_name = suggested_name[:10] + '...' + suggested_name[-10:]
fobj = tempfile.NamedTemporaryFile(dir=tmpdir.name, delete=False,
suffix=suggested_name)
self.files.append(fobj)