Index | Files

package files

import ""

Package files implements the blobserver interface by storing each blob in its own file in nested directories. Users don't use the "files" type directly; it's used by "localdisk" and in the future "sftp" and "webdav".


Package Files

enumerate.go files.go osfs.go osfs_posix.go receive.go

type ReadableFile Uses

type ReadableFile interface {

ReadableFile is the interface required by read-only files returned by VFS.Open.

type Storage Uses

type Storage struct {
    // contains filtered or unexported fields

func NewStorage Uses

func NewStorage(fs VFS, root string) *Storage

func (*Storage) EnumerateBlobs Uses

func (ds *Storage) EnumerateBlobs(ctx context.Context, dest chan<- blob.SizedRef, after string, limit int) error

func (*Storage) Fetch Uses

func (ds *Storage) Fetch(ctx context.Context, br blob.Ref) (io.ReadCloser, uint32, error)

func (*Storage) ReceiveBlob Uses

func (ds *Storage) ReceiveBlob(ctx context.Context, blobRef blob.Ref, source io.Reader) (blob.SizedRef, error)

func (*Storage) RemoveBlobs Uses

func (ds *Storage) RemoveBlobs(ctx context.Context, blobs []blob.Ref) error

func (*Storage) SetNewFileGate Uses

func (s *Storage) SetNewFileGate(g *syncutil.Gate)

SetNewFileGate sets a gate (counting semaphore) on the number of new files that may be opened for writing at a time.

func (*Storage) StatBlobs Uses

func (ds *Storage) StatBlobs(ctx context.Context, blobs []blob.Ref, fn func(blob.SizedRef) error) error

func (*Storage) SubFetch Uses

func (ds *Storage) SubFetch(ctx context.Context, br blob.Ref, offset, length int64) (io.ReadCloser, error)

type VFS Uses

type VFS interface {
    Remove(string) error // files, not directories
    RemoveDir(string) error
    Stat(string) (os.FileInfo, error)
    Lstat(string) (os.FileInfo, error)
    Open(string) (ReadableFile, error)
    MkdirAll(path string, perm os.FileMode) error

    // Rename is a POSIX-style rename, overwriting newname if it exists.
    Rename(oldname, newname string) error

    // TempFile should behave like io/ioutil.TempFile.
    TempFile(dir, prefix string) (WritableFile, error)

    ReadDirNames(dir string) ([]string, error)

VFS describes the virtual filesystem needed by this package.

It is currently not possible to use this from other packages, but that will change.

func OSFS Uses

func OSFS() VFS

OSFS returns an implementation of VFS interface using the host filesystem.

type WritableFile Uses

type WritableFile interface {
    // Name returns the full path to the file.
    // It should behave like (*os.File).Name.
    Name() string
    // Sync fsyncs the file, like (*os.File).Sync.
    Sync() error

WritableFile is the interface required by files opened for Write from VFS.TempFile.

Package files imports 14 packages (graph) and is imported by 2 packages. Updated 2019-06-24. Refresh now. Tools for package owners.