qri: github.com/qri-io/qri/fsi Index | Files

package fsi

import "github.com/qri-io/qri/fsi"

Package fsi defines qri file system integration: representing a dataset as files in a directory on a user's computer. Using fsi, users can edit files as an interface for working with qri datasets.

A dataset is "linked" to a directory through a `.qri_ref` dotfile that connects the folder to a version history stored in the local qri repository.

files in a linked directory follow naming conventions that map to components of a dataset. eg: a file named "meta.json" in a linked directory maps to the dataset meta component. This mapping can be used to construct a dataset for read and write actions

Index

Package Files

body.go fsi.go init.go mapping.go set_file.go status.go

Constants

const QriRefFilename = ".qri-ref"

QriRefFilename is the name of the file that links a folder to a dataset. The file contains a dataset reference that declares the link ref files are the authoritative definition of weather a folder is linked or not

Variables

var (
    // STUnmodified is "no status"
    STUnmodified = "unmodified"
    // STAdd is an added component
    STAdd = "add"
    // STChange is a modified component
    STChange = "modified"
    // STRemoved is a removed component
    STRemoved = "removed"
    // STParseError is a component that didn't parse
    STParseError = "parse error"
)
var (
    // ErrNoDatasetFiles indicates no data
    ErrNoDatasetFiles = fmt.Errorf("no dataset files provided")
)

func DeleteComponents Uses

func DeleteComponents(removeList []string, fileMap map[string]FileStat, dirPath string) error

DeleteComponents removes the list of named components from the given directory

func DeleteDatasetFiles Uses

func DeleteDatasetFiles(dirPath string) (removed map[string]FileStat, err error)

DeleteDatasetFiles removes mapped files from a directory. if the result of deleting all files leaves the directory empty, it will remove the directory as well

func GetBody Uses

func GetBody(dirPath string, format dataset.DataFormat, fcfg dataset.FormatConfig, offset, limit int, all bool) ([]byte, error)

GetBody is an FSI version of actions.GetBody

func GetLinkedFilesysRef Uses

func GetLinkedFilesysRef(dir string) (string, bool)

GetLinkedFilesysRef returns whether a directory is linked to a dataset in your repo, and the reference to that dataset.

func OpenEntryReader Uses

func OpenEntryReader(file *os.File, format string) (dsio.EntryReader, error)

OpenEntryReader opens a entry reader for the file, determining the schema automatically

func ReadDir Uses

func ReadDir(dir string) (ds *dataset.Dataset, fileMap, problems map[string]FileStat, err error)

ReadDir parses a directory into a dataset, returning both the dataset and a map of component names to the files they came from. Files can be specified in either JSON or YAML format. It is an error to specify any component more than once

func RepoPath Uses

func RepoPath(repoPath string) string

RepoPath returns the standard path to an FSI file for a given file-system repo location

func WriteComponents Uses

func WriteComponents(ds *dataset.Dataset, dirPath string) error

WriteComponents writes components of the dataset to the given path, as individual files.

type FSI Uses

type FSI struct {
    // contains filtered or unexported fields
}

FSI is a repo-side struct for coordinating file system integration

func NewFSI Uses

func NewFSI(r repo.Repo) *FSI

NewFSI creates an FSI instance from a path to a links flatbuffer file

func (*FSI) AliasToLinkedDir Uses

func (fsi *FSI) AliasToLinkedDir(alias string) (string, error)

AliasToLinkedDir converts the given dataset alias to the FSI path it is linked to.

func (*FSI) CalculateStateTransition Uses

func (fsi *FSI) CalculateStateTransition(ctx context.Context, prev, next *dataset.Dataset, fileMap, problems map[string]FileStat) (changes []StatusItem, err error)

CalculateStateTransition calculates the differences between two versions of a dataset.

func (fsi *FSI) CreateLink(dirPath, refStr string) (string, error)

CreateLink connects a directory

func (*FSI) InitDataset Uses

func (fsi *FSI) InitDataset(p InitParams) (name string, err error)

InitDataset creates a new dataset

func (*FSI) LinkedRefs Uses

func (fsi *FSI) LinkedRefs(offset, limit int) ([]repo.DatasetRef, error)

LinkedRefs returns a list of linked datasets and their connected directories

func (*FSI) Status Uses

func (fsi *FSI) Status(ctx context.Context, dir string) (changes []StatusItem, err error)

Status compares status of the current working directory against the dataset's last version

func (*FSI) StatusAtVersion Uses

func (fsi *FSI) StatusAtVersion(ctx context.Context, refStr string) (changes []StatusItem, err error)

StatusAtVersion gets changes that happened at a particular version in a dataset's history.

func (fsi *FSI) Unlink(dirPath, refStr string) error

Unlink breaks the connection between a directory and a dataset

func (fsi *FSI) UpdateLink(dirPath, refStr string) (string, error)

UpdateLink changes an existing link entry

type FileStat Uses

type FileStat struct {
    Path  string
    Mtime time.Time
}

FileStat holds information about a file: its path and mod time

type InitParams Uses

type InitParams struct {
    Dir            string
    Name           string
    Format         string
    Mkdir          string
    SourceBodyPath string
}

InitParams encapsulates parameters for fsi.InitDataset

type StatusItem Uses

type StatusItem struct {
    SourceFile string    `json:"sourceFile"`
    Component  string    `json:"component"`
    Type       string    `json:"type"`
    Message    string    `json:"message"`
    Mtime      time.Time `json:"mtime"`
}

StatusItem is a component that has status representation on the filesystem

func (StatusItem) MarshalJSON Uses

func (si StatusItem) MarshalJSON() ([]byte, error)

MarshalJSON marshals a StatusItem, handling mtime specially

Package fsi imports 20 packages (graph) and is imported by 2 packages. Updated 2019-09-17. Refresh now. Tools for package owners.