resticfs

package
v1.1.16 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: BSD-2-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInUse = errors.New("file is currently open for writing")

ErrInUse indicates that a snapshot couldn't be made because of ongoing writes.

View Source
var ErrNoChanges = errors.New("no changes to commit")

ErrNoChanges indicates that a snapshot was not created because it would be identical to the parent snapshot.

View Source
var ErrNotDirectory = errors.New("file is not a directory")

ErrNotDirectory indicates that a file is attempting to be opened as a directory

Functions

This section is empty.

Types

type Filesystem

type Filesystem struct {

	// Temporary is the backing store for temporary files created by the
	// Filesystem. The default value for Temporary is an osfs.FileSystem, but a
	// custom value can be provided here.
	Temporary billy.Filesystem
	// Logger can be provided to enable detailed logging of operations.
	Logger *log.Logger
	// contains filtered or unexported fields
}

Filesystem satisfies billy.Filesystem and allows reading and writing restic snapshots. By default, Filesystems are read-only, writing can be enabled using the StartNewSnapshot method.

func New

func New(ctx context.Context, repo restic.Repository, parentSnapshotID *restic.ID) (*Filesystem, error)

New returns a new, read-only Filesystem based on the provided restic.Repository and snapshot ID. If the snapshot ID is nil, the Filesystem will be initially empty. The caller is responsible for properly locking and unlocking the restic repository.

func (*Filesystem) CommitSnapshot

func (fs *Filesystem) CommitSnapshot(path string, tags []string) (id restic.ID, err error)

CommitSnapshot commits all pending changes to restic, then saves the resulting as a tree as a new snapshot. May return ErrNoChanges if commiting a snapshot would be redundant.

func (*Filesystem) Create

func (fs *Filesystem) Create(filename string) (billy.File, error)

Create creates the named file with mode 0666 (before umask), truncating it if it already exists. If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode O_RDWR.

func (*Filesystem) Join

func (fs *Filesystem) Join(elem ...string) string

Join joins any number of path elements into a single path, adding a Separator if necessary. Join calls filepath.Clean on the result; in particular, all empty strings are ignored. On Windows, the result is a UNC path if and only if the first path element is a UNC path.

func (*Filesystem) MkdirAll

func (fs *Filesystem) MkdirAll(path string, perm os.FileMode) (err error)

MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm are used for all directories that MkdirAll creates. If path is/ already a directory, MkdirAll does nothing and returns nil.

func (*Filesystem) Open

func (fs *Filesystem) Open(filename string) (billy.File, error)

Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY.

func (*Filesystem) OpenFile

func (fs *Filesystem) OpenFile(fullpath string, flag int, perm os.FileMode) (file billy.File, err error)

OpenFile is the generalized open call; most users will use Open or Create instead. It opens the named file with specified flag (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful, methods on the returned File can be used for I/O.

func (*Filesystem) ReadDir

func (fs *Filesystem) ReadDir(path string) (result []os.FileInfo, err error)

ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename.

func (*Filesystem) Remove

func (fs *Filesystem) Remove(fullpath string) (err error)

Remove removes the named file or directory.

func (*Filesystem) Rename

func (fs *Filesystem) Rename(oldpath, newpath string) (err error)

Rename renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories.

func (*Filesystem) StartNewSnapshot

func (fs *Filesystem) StartNewSnapshot()

StartNewSnapshot enables writing to this Filesystem. Writing to files is accomplished using Temporary, and only when the file is closed is the data actually written to the restic repository. Further, the data will be orphaned until the CommitSnapshot method is called.

func (*Filesystem) Stat

func (fs *Filesystem) Stat(fullpath string) (fi os.FileInfo, err error)

Stat returns a FileInfo describing the named file.

func (*Filesystem) TempFile

func (fs *Filesystem) TempFile(dir, prefix string) (billy.File, error)

TempFile creates a new temporary file in the directory dir with a name beginning with prefix, opens the file for reading and writing, and returns the resulting *os.File. If dir is the empty string, TempFile uses the default directory for temporary files (see os.TempDir). Multiple programs calling TempFile simultaneously will not choose the same file. The caller can use f.Name() to find the pathname of the file. It is the caller's responsibility to remove the file when no longer needed.

type NodeInfo

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

NodeInfo satisfies os.FileInfo for a *restic.Node.

func (NodeInfo) Backing

func (n NodeInfo) Backing() billy.File

Backing returns the underlying datastore for the file's data. Since it is accessed by each file handle, it needs to be concurrency-safe. When a file is converted from read-only to writeable, the backing store is swapped out, which means that existing readers transparently start accessing the copy and have consistent reads.

func (NodeInfo) Commit

func (n NodeInfo) Commit() (err error)

Commit will persist any modifications to the restic repository.

func (NodeInfo) IsDir

func (n NodeInfo) IsDir() bool

IsDir satisfies os.FileInfo

func (NodeInfo) ModTime

func (n NodeInfo) ModTime() time.Time

ModTime satisfies os.FileInfo

func (NodeInfo) Mode

func (n NodeInfo) Mode() os.FileMode

Mode satisfies os.FileInfo

func (NodeInfo) Name

func (n NodeInfo) Name() string

Name satisfies os.FileInfo

func (NodeInfo) Open

func (n NodeInfo) Open(name string, flag int, perm os.FileMode) (billy.File, error)

Open should create a handle to the file backed by this node.

func (NodeInfo) OpenSubtree

func (n NodeInfo) OpenSubtree() (*resticTree, error)

func (NodeInfo) Rename

func (n NodeInfo) Rename(newtree *resticTree, newname string) error

Rename moves this node into the new tree under the new name.

func (NodeInfo) SetBacking

func (n NodeInfo) SetBacking(val billy.File)

func (NodeInfo) Size

func (n NodeInfo) Size() int64

Size satisfies os.FileInfo

func (NodeInfo) Sys

func (n NodeInfo) Sys() interface{}

Sys satisfies os.FileInfo

Jump to

Keyboard shortcuts

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