Fix #6: check path matches, rather than blindly selecting metadata #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #6 by checking the path within each entry with a matching checksum to ensure it matches the path of the file we're currently opening. Tested and confirmed working on Linux, and should work on any Posix system. Needs testing on Windows.
More Detailed Explanation
Previously, it was assumed in freezefs that the first freezetag entry with a matching checksum corresponded to the correct metadata. However, this is not a valid assumption, and this edge case is correctly handled by the
thaw
command but not by themount
command. To rectify this, thetarget_path
is generated from the path stored in thefrozen_entry
, which is of the form/freezetag_root/path/to/file.ext
. Correct me if this assumption is wrong, but from my testing it seems that any file referenced by a freezetag file, regardless of where it is stored on the real filesystem or where it is stored relative to the freezetag file, is added to the freezefs at its relative path from the root directory stored in the freezetag file (though one possible edge case I can think of is a freezetag file where the root is/
). The first two components of this path,/
andfreezetag_root
are removed, and the remaining parts,path
,to
andfile.ext
are joined intopath/to/file.ext
. This matches the form of the path in each entry offreezetag.data.frozen.files
, so we can compare the two paths whenever the checksum matches to ensure we are selecting the correct metadata.This solution will need testing on Windows, as I am not sure whether joining the parts of the path using the
/
character is appropriate. I am not sure exactly how thefreezetag.data.frozen.files
paths are represented on a Windows system. It may be necessary to join the paths usingos.path.sep
instead. Unfortunately, I do not have a Windows computer to hand with the correct environment to test this myself, so if someone else could test this, that would be great.