fsi

package
v0.9.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

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

Constants

View Source
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

View Source
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"
)
View Source
var (
	// ErrNoDatasetFiles indicates no data
	ErrNoDatasetFiles = fmt.Errorf("no dataset files provided")
)

Functions

func DeleteComponents

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

DeleteComponents removes the list of named components from the given directory

func GetBody

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

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 ReadDir

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

func RepoPath(repoPath string) string

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

func WriteComponents

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

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

Types

type FSI

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

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

func NewFSI

func NewFSI(r repo.Repo) *FSI

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

func (*FSI) AliasToLinkedDir

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

func (fsi *FSI) CalculateStateTransition(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

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

InitDataset creates a new dataset

func (*FSI) LinkedRefs

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

LinkedRefs returns a list of linked datasets and their connected directories

func (*FSI) Status

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

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

func (*FSI) StatusAtVersion

func (fsi *FSI) StatusAtVersion(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

type FileStat struct {
	Path  string
	Mtime time.Time
}

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

type InitParams

type InitParams struct {
	Filepath string
	Name     string
	Format   string
}

InitParams encapsulates parameters for fsi.InitDataset

type StatusItem

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

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

MarshalJSON marshals a StatusItem, handling mtime specially

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL