Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6: check path matches, rather than blindly selecting metadata #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions freezetag/freezefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@ def open(self, path, flags):
if not frozen_entry:
raise FuseOSError(ENOENT)

# This is the path, relative to the freezetag file's root, that we are trying to open.
# Knowing this is essential to providing the correct metadata.
#
# TODO: validate that this is correct on all operating systems.
target_path = "/".join(frozen_entry.path.parts[2:])

freezetag_path = None
metadata = None
if frozen_entry.metadata_len:
Expand All @@ -383,8 +389,11 @@ def open(self, path, flags):

for f in freezetag.data.frozen.files:
if f.checksum == item.checksum:
metadata = f.metadata
break
if f.path == target_path:
self._log_verbose(f'opened {f.path} as {path} (target: {target_path})')
metadata = f.metadata
break
self._log_verbose(f'ignoring {f.path} despite matching checksum (target: {target_path})')

file = FuseFile.from_info(file_entry.path, flags, metadata, file_entry.metadata_info, file_entry.metadata_len,
frozen_entry.metadata_len)
Expand Down