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

Implement an iofs.FS over the REAPI Tree proto #2955

Merged
merged 12 commits into from
Nov 15, 2023

Conversation

Tatskaari
Copy link
Member

No description provided.

return nil, os.ErrNotExist
}

// openFile downloads a file from the CAS and returns it as an iofs.File
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it returns it as an iofs.File

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah as in *file implements the iofs.File interface

func (fs *CASFileSystem) findNode(wd *pb.Directory, name string) (*pb.FileNode, *pb.DirectoryNode, *pb.SymlinkNode, error) {
name, rest, hasToBeDir := strings.Cut(name, string(filepath.Separator))
// Must be a dodgy symlink that goes past our tree.
if name == ".." || name == "." {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think "." should be ErrNotExist

mode: os.FileMode(file.NodeProperties.UnixMode.Value),
// Technically we could calculate this on demand by allowing info.Size() to download the file from the
// CAS... we don't need to for now though.
size: 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought the CAS stored the filesize without us needing to download it and calculated this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah! It's on the digest! Nice spot.

*info
}

// ReadDir is a slightly incorrect implementation of ReadDir. It deviates slightly as it will report all files have 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment should be updated now we have the filesize

goddenrich
goddenrich approved these changes Nov 15, 2023
@Tatskaari Tatskaari merged commit 27b56d3 into thought-machine:master Nov 15, 2023
10 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants