Skip to content

Commit

Permalink
Changed HFS back-end to prefer look up by identifier (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz authored Apr 19, 2022
1 parent 5bd80e7 commit 4a84328
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions dfvfs/vfs/apfs_file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def FileEntryExistsByPathSpec(self, path_spec):
Raises:
BackEndError: if the file entry cannot be opened.
"""
# Opening a file by identifier by location will ensure added time is
# provided when available.
# Opening a file by location will ensure added time is provided when
# available.
fsapfs_file_entry = None
location = getattr(path_spec, 'location', None)
identifier = getattr(path_spec, 'identifier', None)
Expand Down Expand Up @@ -119,8 +119,8 @@ def GetFileEntryByPathSpec(self, path_spec):
Raises:
BackEndError: if the file entry cannot be opened.
"""
# Opening a file by identifier by location will ensure added time is
# provided when available.
# Opening a file by location will ensure added time is provided when
# available.
fsapfs_file_entry = None
location = getattr(path_spec, 'location', None)
identifier = getattr(path_spec, 'identifier', None)
Expand Down Expand Up @@ -162,8 +162,8 @@ def GetAPFSFileEntryByPathSpec(self, path_spec):
PathSpecError: if the path specification is missing location and
identifier.
"""
# Opening a file by identifier by location will ensure added time is
# provided when available.
# Opening a file by location will ensure added time is provided when
# available.
location = getattr(path_spec, 'location', None)
identifier = getattr(path_spec, 'identifier', None)

Expand Down
24 changes: 12 additions & 12 deletions dfvfs/vfs/hfs_file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ def FileEntryExistsByPathSpec(self, path_spec):
Raises:
BackEndError: if the file entry cannot be opened.
"""
# Opening a file by location is faster than opening a file by identifier.
# Opening a file by identifier is faster than opening a file by location.
fshfs_file_entry = None
location = getattr(path_spec, 'location', None)
identifier = getattr(path_spec, 'identifier', None)

try:
if location is not None:
fshfs_file_entry = self._fshfs_volume.get_file_entry_by_path(location)
elif identifier is not None:
if identifier is not None:
fshfs_file_entry = self._fshfs_volume.get_file_entry_by_identifier(
identifier)
elif location is not None:
fshfs_file_entry = self._fshfs_volume.get_file_entry_by_path(location)

except IOError as exception:
raise errors.BackEndError(exception)
Expand All @@ -104,7 +104,7 @@ def GetFileEntryByPathSpec(self, path_spec):
Raises:
BackEndError: if the file entry cannot be opened.
"""
# Opening a file by location is faster than opening a file by identifier.
# Opening a file by identifier is faster than opening a file by location.
fshfs_file_entry = None
location = getattr(path_spec, 'location', None)
identifier = getattr(path_spec, 'identifier', None)
Expand All @@ -117,11 +117,11 @@ def GetFileEntryByPathSpec(self, path_spec):
fshfs_file_entry=fshfs_file_entry, is_root=True)

try:
if location is not None:
fshfs_file_entry = self._fshfs_volume.get_file_entry_by_path(location)
elif identifier is not None:
if identifier is not None:
fshfs_file_entry = self._fshfs_volume.get_file_entry_by_identifier(
identifier)
elif location is not None:
fshfs_file_entry = self._fshfs_volume.get_file_entry_by_path(location)

except IOError as exception:
raise errors.BackEndError(exception)
Expand All @@ -146,15 +146,15 @@ def GetHFSFileEntryByPathSpec(self, path_spec):
PathSpecError: if the path specification is missing location and
identifier.
"""
# Opening a file by location is faster than opening a file by identifier.
# Opening a file by identifier is faster than opening a file by location.
location = getattr(path_spec, 'location', None)
identifier = getattr(path_spec, 'identifier', None)

if location is not None:
fshfs_file_entry = self._fshfs_volume.get_file_entry_by_path(location)
elif identifier is not None:
if identifier is not None:
fshfs_file_entry = self._fshfs_volume.get_file_entry_by_identifier(
identifier)
elif location is not None:
fshfs_file_entry = self._fshfs_volume.get_file_entry_by_path(location)
else:
raise errors.PathSpecError(
'Path specification missing location and identifier.')
Expand Down

0 comments on commit 4a84328

Please sign in to comment.