mirror of https://github.com/CIRCL/PyCIRCLean
Several small bugfixes
* Fix issue with main/subtypes in init * Fix bug in File.check() in filecheck.py * Fix FileBase.size for symlinkspull/12/head
parent
3fe8c7c223
commit
18857da7ca
|
@ -162,8 +162,10 @@ class File(FileBase):
|
||||||
|
|
||||||
def check(self):
|
def check(self):
|
||||||
self._check_dangerous()
|
self._check_dangerous()
|
||||||
self._check_extension()
|
if self.has_extension():
|
||||||
self._check_mimetype()
|
self._check_extension()
|
||||||
|
if self.has_mimetype():
|
||||||
|
self._check_mimetype()
|
||||||
if not self.is_dangerous():
|
if not self.is_dangerous():
|
||||||
self.mime_processing_options.get(self.main_type, self.unknown)()
|
self.mime_processing_options.get(self.main_type, self.unknown)()
|
||||||
|
|
||||||
|
|
|
@ -61,10 +61,14 @@ class FileBase(object):
|
||||||
self.set_property('extension', self.extension)
|
self.set_property('extension', self.extension)
|
||||||
self.mimetype = self._determine_mimetype()
|
self.mimetype = self._determine_mimetype()
|
||||||
self.should_copy = True
|
self.should_copy = True
|
||||||
|
self.main_type = None
|
||||||
|
self.sub_type = None
|
||||||
if self.mimetype:
|
if self.mimetype:
|
||||||
self.main_type, self.sub_type = self._split_subtypes(self.mimetype)
|
self.main_type, self.sub_type = self._split_subtypes(self.mimetype)
|
||||||
self.set_property('maintype', self.main_type)
|
if self.main_type:
|
||||||
self.set_property('subtype', self.sub_type)
|
self.set_property('maintype', self.main_type)
|
||||||
|
if self.sub_type:
|
||||||
|
self.set_property('subtype', self.sub_type)
|
||||||
|
|
||||||
def _determine_extension(self):
|
def _determine_extension(self):
|
||||||
_, ext = os.path.splitext(self.src_path)
|
_, ext = os.path.splitext(self.src_path)
|
||||||
|
@ -102,7 +106,11 @@ class FileBase(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def size(self):
|
def size(self):
|
||||||
return os.path.getsize(self.src_path)
|
try:
|
||||||
|
size = os.path.getsize(self.src_path)
|
||||||
|
except FileNotFoundError:
|
||||||
|
size = 0
|
||||||
|
return size
|
||||||
|
|
||||||
def has_mimetype(self):
|
def has_mimetype(self):
|
||||||
"""Returns True if file has a full mimetype, else False."""
|
"""Returns True if file has a full mimetype, else False."""
|
||||||
|
|
Loading…
Reference in New Issue