sync

package
v0.0.0-...-b8b0f03 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCASKey

func CreateCASKey(filename string) (string, error)

CreateCASKey creates a content-addressable key for the given file.

Types

type Index

type Index struct {
	Objects []*Object
}

Index tracks which objects are stored in a bucket.

func (*Index) Add

func (i *Index) Add(key string, tags string, filepath string, isNew bool)

Add adds a new object to the index.

func (*Index) Diff

func (i *Index) Diff(index *Index) *Index

Diff builds a new index containing objects present in the supplied index but not the origin.

func (*Index) LoadJSON

func (i *Index) LoadJSON(data []byte) error

LoadJSON unmarshals the supplied JSON data into a set of objects.

func (*Index) SaveJSON

func (i *Index) SaveJSON() ([]byte, error)

SaveJSON marshals the data to JSON.

type Object

type Object struct {
	Key      string `json:"key"`
	Tags     string `json:"tags"`
	Filepath string `json:"-"`
	IsNew    bool   `json:"-"`
}

Object holds data about a key and its tags.

type ObjectStore

type ObjectStore interface {
	Get(key string) ([]byte, error)
	Put(key string, contentType string, data io.ReadSeeker) error
}

ObjectStore describes an object capable of storing and retrieving data for a given key.

type S3Store

type S3Store struct {
	Bucket string
	Region string
}

S3Store is an implementation of the storage interface that uses S3 as the store.

func (*S3Store) Get

func (s *S3Store) Get(key string) ([]byte, error)

Get retrieves the data for the given key.

func (*S3Store) Put

func (s *S3Store) Put(key string, contentType string, data io.ReadSeeker) error

Put saves the data under the given key in S3.

type Syncer

type Syncer struct {
	Store ObjectStore
	Log   func(string, ...interface{})
}

Syncer synchronises files from a directory to a storage service.

func (*Syncer) Run

func (s *Syncer) Run(dir string, exts string) (string, error)

Run begins a sync using the specified directory.

Jump to

Keyboard shortcuts

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