mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
catch maxpath error in mediasrv
https://anki.tenderapp.com/discussions/ankidesktop/30729-valueerror-in-ospathisdir-call-in-mediasrvpy-for-elements-with-long-strings-as-src
This commit is contained in:
parent
7f85218b5a
commit
6e95d9a398
1 changed files with 9 additions and 1 deletions
|
@ -82,9 +82,17 @@ class RequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||||
def send_head(self):
|
def send_head(self):
|
||||||
path = self.translate_path(self.path)
|
path = self.translate_path(self.path)
|
||||||
path = self._redirectWebExports(path)
|
path = self._redirectWebExports(path)
|
||||||
if os.path.isdir(path):
|
try:
|
||||||
|
isdir = os.path.isdir(path)
|
||||||
|
except ValueError:
|
||||||
|
# path too long exception on Windows
|
||||||
self.send_error(HTTPStatus.NOT_FOUND, "File not found")
|
self.send_error(HTTPStatus.NOT_FOUND, "File not found")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if isdir:
|
||||||
|
self.send_error(HTTPStatus.NOT_FOUND, "File not found")
|
||||||
|
return None
|
||||||
|
|
||||||
ctype = self.guess_type(path)
|
ctype = self.guess_type(path)
|
||||||
try:
|
try:
|
||||||
f = open(path, 'rb')
|
f = open(path, 'rb')
|
||||||
|
|
Loading…
Reference in a new issue