mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Fix news download with unicode temp path
This commit is contained in:
parent
4e219458b0
commit
7b6c55865c
@ -201,6 +201,24 @@ class RecursiveFetcher(object):
|
|||||||
def fetch_url(self, url):
|
def fetch_url(self, url):
|
||||||
data = None
|
data = None
|
||||||
self.log.debug('Fetching', url)
|
self.log.debug('Fetching', url)
|
||||||
|
|
||||||
|
# Check for a URL pointing to the local filesystem and special case it
|
||||||
|
# for efficiency and robustness. Bypasses delay checking as it does not
|
||||||
|
# apply to local fetches. Ensures that unicode paths that are not
|
||||||
|
# representable in the filesystem_encoding work.
|
||||||
|
is_local = 0
|
||||||
|
if url.startswith('file://'):
|
||||||
|
is_local = 7
|
||||||
|
elif url.startswith('file:'):
|
||||||
|
is_local = 5
|
||||||
|
if is_local > 0:
|
||||||
|
url = url[is_local:]
|
||||||
|
with open(url, 'rb') as f:
|
||||||
|
data = response(f.read())
|
||||||
|
data.newurl = 'file:'+url # This is what mechanize does for
|
||||||
|
# local URLs
|
||||||
|
return data
|
||||||
|
|
||||||
delta = time.time() - self.last_fetch_at
|
delta = time.time() - self.last_fetch_at
|
||||||
if delta < self.delay:
|
if delta < self.delay:
|
||||||
time.sleep(self.delay - delta)
|
time.sleep(self.delay - delta)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user