mirror of https://github.com/CIRCL/PyCIRCLean
Do not fail on broken symlink
parent
6bc83f947d
commit
d6476dab38
|
@ -37,11 +37,15 @@ class FileBase(object):
|
||||||
self.log_string = ''
|
self.log_string = ''
|
||||||
a, self.extension = os.path.splitext(self.src_path)
|
a, self.extension = os.path.splitext(self.src_path)
|
||||||
|
|
||||||
mt = magic.from_file(self.src_path, mime=True)
|
if os.path.islink(self.src_path):
|
||||||
try:
|
# magic will throw an IOError on a broken symlink
|
||||||
self.mimetype = mt.decode("utf-8")
|
self.mimetype = 'inode/symlink'
|
||||||
except:
|
else:
|
||||||
self.mimetype = mt
|
mt = magic.from_file(self.src_path, mime=True)
|
||||||
|
try:
|
||||||
|
self.mimetype = mt.decode("utf-8")
|
||||||
|
except:
|
||||||
|
self.mimetype = mt
|
||||||
|
|
||||||
if self.mimetype and '/' in self.mimetype:
|
if self.mimetype and '/' in self.mimetype:
|
||||||
self.main_type, self.sub_type = self.mimetype.split('/')
|
self.main_type, self.sub_type = self.mimetype.split('/')
|
||||||
|
|
Loading…
Reference in New Issue