Example #1
0
func (d *directory) Lookup(ctx context.Context, name string) (fs.Node, error) {
	if d.commitID == "" {
		commitInfo, err := pfsutil.GetCommitInfo(
			d.fs.apiClient,
			d.fs.repositoryName,
			name,
		)
		if err != nil {
			return nil, err
		}
		if commitInfo == nil {
			return nil, fuse.ENOENT
		}
		return &directory{
				d.fs,
				name,
				commitInfo.CommitType == pfs.CommitType_COMMIT_TYPE_WRITE,
				"",
			},
			nil
	}
	fileInfo, err := pfsutil.GetFileInfo(
		d.fs.apiClient,
		d.fs.repositoryName,
		d.commitID,
		path.Join(d.path, name),
	)
	if err != nil {
		return nil, err
	}
	return d.nodeFromFileInfo(fileInfo)
}
Example #2
0
func (f *file) Attr(ctx context.Context, a *fuse.Attr) error {
	fileInfo, err := pfsutil.GetFileInfo(
		f.fs.apiClient,
		f.fs.repositoryName,
		f.commitID,
		f.path,
	)
	if err != nil {
		return err
	}
	if fileInfo != nil {
		a.Size = fileInfo.SizeBytes
	}
	a.Mode = 0666
	return nil
}