From 7a75239843716d1bf0ff9d0e571d6e7dd35e8926 Mon Sep 17 00:00:00 2001 From: John Schember Date: Tue, 20 Sep 2011 20:17:49 -0400 Subject: [PATCH] Store: Download, ensure download filename is ascii. --- src/calibre/__init__.py | 6 +++++- src/calibre/gui2/ebook_download.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index 358a7ee4bf..ef6a383925 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -17,6 +17,7 @@ from calibre.constants import (iswindows, isosx, islinux, isfrozen, win32event, win32api, winerror, fcntl, filesystem_encoding, plugins, config_dir) from calibre.startup import winutil, winutilerror +from calibre.utils.filenames import ascii_filename if False and islinux and not getattr(sys, 'frozen', False): # Imported before PyQt4 to workaround PyQt4 util-linux conflict discovered on gentoo @@ -648,7 +649,10 @@ def get_download_filename(url, cookie_file=None): if not filename: filename = last_part_name - return filename + filename, ext = os.path.splitext(filename) + filename = filename[:60] + ext + + return ascii_filename(filename) def human_readable(size): """ Convert a size in bytes into a human readable form """ diff --git a/src/calibre/gui2/ebook_download.py b/src/calibre/gui2/ebook_download.py index df44b52af2..d39ea47e52 100644 --- a/src/calibre/gui2/ebook_download.py +++ b/src/calibre/gui2/ebook_download.py @@ -44,7 +44,7 @@ class EbookDownload(object): return dfilename if not filename: - filename = get_download_filename(url, cookie_file)[:60] + filename = get_download_filename(url, cookie_file) br = browser() if cookie_file: