updater

package
v0.0.0-...-541cb8d Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Username string
	Password string
}

Auth holds authentication for the http basic auth

type Config

type Config struct {
	IsUpdating bool
	Username   string
	Password   string
	Enabled    bool
	Workers    int
	Empty      bool
	Port       int
}

func (Config) CheckInfo

func (u Config) CheckInfo() error

type ProgressReader

type ProgressReader struct {
	io.Reader
	Reporter func(r int64)
}

ProgressReader implements a io.Reader with a Read function that lets a callback report how much of the file was read

func (*ProgressReader) Read

func (pr *ProgressReader) Read(p []byte) (n int, err error)

type ResponseInit

type ResponseInit struct {
	Success bool
	Hashes  map[string]string
}

ResponseInit holds a list of hashes from the server to be sent to the client so it can check if there is a new file or a changed file

type Updater

type Updater struct {
	Server string
	Auth   Auth

	RemoteHashes map[string]string
	LocalHashes  map[string]string
	ToUpdate     []string
	Workers      int
}

Updater sends files that should be update to the b0x server

func (*Updater) EqualHash

func (up *Updater) EqualHash(name string) bool

EqualHash checks if a local file hash equals a remote file hash it returns false when a remote file hash isn't found (new files)

func (*Updater) EqualHashes

func (up *Updater) EqualHashes(files map[string]*file.File) bool

EqualHashes builds the list of local hashes before checking if there is any that should be updated

func (*Updater) Get

func (up *Updater) Get() error

Get gets the list of file hash from the server

func (*Updater) Init

func (up *Updater) Init() error

Init gets the list of file hash from the server

func (*Updater) Updatable

func (up *Updater) Updatable(files map[string]*file.File) (bool, error)

Updatable checks if there is any file that should be updaTed

func (*Updater) UpdateFiles

func (up *Updater) UpdateFiles(files map[string]*file.File) error

UpdateFiles sends all files that should be updated to the server the limit is 3 concurrent files at once

Jump to

Keyboard shortcuts

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