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:
parent
9973cd5037
commit
abcdaa9cce
@ -1322,6 +1322,9 @@ class TempDownloadManager(QObject):
|
|||||||
A tempfile.NamedTemporaryFile that should be used to save the file.
|
A tempfile.NamedTemporaryFile that should be used to save the file.
|
||||||
"""
|
"""
|
||||||
tmpdir = self._get_tmpdir()
|
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,
|
fobj = tempfile.NamedTemporaryFile(dir=tmpdir.name, delete=False,
|
||||||
suffix=suggested_name)
|
suffix=suggested_name)
|
||||||
self.files.append(fobj)
|
self.files.append(fobj)
|
||||||
|
Loading…
Reference in New Issue
Block a user