Skip to content

Commit

Permalink
Changes to file system searcher for mount point check (#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz authored Feb 10, 2021
1 parent fb6cd81 commit 281abf1
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions dfvfs/helpers/file_system_searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,21 +370,17 @@ def CompareLocation(self, file_entry, mount_point=None):
location defined.
Raises:
ValueError: if mount point is set and it does not match the type
indicator of the path specification of the file entry or file entry
location falls outside the mount point.
ValueError: if mount point is set and is of type OS and the location of
the path specification of the file entry falls outside the mount
point.
"""
location = getattr(file_entry.path_spec, 'location', None)
if self._location_segments is None or location is None:
return False

if (mount_point and
mount_point.type_indicator == definitions.TYPE_INDICATOR_OS):
if file_entry.path_spec.type_indicator != definitions.TYPE_INDICATOR_OS:
raise ValueError(
'File entry path specification and mount point type indicators '
'do not match.')

mount_point.type_indicator == definitions.TYPE_INDICATOR_OS and
file_entry.path_spec.type_indicator == definitions.TYPE_INDICATOR_OS):
if not location.startswith(mount_point.location):
raise ValueError(
'File entry path specification location not inside mount point.')
Expand Down

0 comments on commit 281abf1

Please sign in to comment.