Do not run file(1) on non-existing files.

This commit is contained in:
Bastian Kleineidam 2010-02-21 14:30:26 +01:00
parent bb7347b03d
commit dde435cc16
1 changed files with 1 additions and 1 deletions

View File

@ -47,7 +47,7 @@ def guess_mime (filename):
"""Guess the MIME type of given filename. Uses first mimetypes
and then file(1) as fallback."""
mime, encoding = mimedb.guess_type(filename, strict=False)
if mime is None:
if mime is None and os.path.isfile(filename):
cmd = ["file", "--brief", "--mime-type", filename]
try:
mime = backtick(cmd).strip()