cacheddownloader

package module
v0.0.0-...-176d84d Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2015 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_DOWNLOAD_ATTEMPTS = 3

Variables

View Source
var (
	EntryNotFound  = errors.New("Entry Not Found")
	NotEnoughSpace = errors.New("No space available")
)
View Source
var ErrDownloadCancelled error = errors.New("Download cancelled")
View Source
var ErrUnknownArchiveFormat = errors.New("unknown archive format")

Functions

func New

func New(cachedPath string, uncachedPath string, maxSizeInBytes int64, downloadTimeout time.Duration, maxConcurrentDownloads int, skipSSLVerification bool) *cachedDownloader

func NoopTransform

func NoopTransform(source, destination string) (int64, error)

func TarTransform

func TarTransform(source string, destination string) (int64, error)

Types

type CacheTransformer

type CacheTransformer func(source, destination string) (newSize int64, err error)

called after a new object has entered the cache. it is assumed that `path` will be removed, if a new path is returned. a noop transformer returns the given path and its detected size.

type CachedDownloader

type CachedDownloader interface {
	Fetch(urlToFetch *url.URL, cacheKey string, transformer CacheTransformer, cancelChan <-chan struct{}) (io.ReadCloser, int64, error)
}

type CachedFile

type CachedFile struct {
	*os.File
	// contains filtered or unexported fields
}

func NewFileCloser

func NewFileCloser(file *os.File, onClose func(string)) *CachedFile

func (*CachedFile) Close

func (fw *CachedFile) Close() error

type CachingInfoType

type CachingInfoType struct {
	ETag         string
	LastModified string
}

func (CachingInfoType) Equal

func (c CachingInfoType) Equal(other CachingInfoType) bool

type Downloader

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

func NewDownloader

func NewDownloader(timeout time.Duration, maxConcurrentDownloads int, skipSSLVerification bool) *Downloader

func (*Downloader) Download

func (downloader *Downloader) Download(
	url *url.URL,
	createDestination func() (*os.File, error),
	cachingInfoIn CachingInfoType,
	cancelChan <-chan struct{},
) (path string, cachingInfoOut CachingInfoType, err error)

type FileCache

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

func NewCache

func NewCache(dir string, maxSizeInBytes int64) *FileCache

func (*FileCache) Add

func (c *FileCache) Add(cacheKey, sourcePath string, size int64, cachingInfo CachingInfoType) (*CachedFile, error)

func (*FileCache) Get

func (c *FileCache) Get(cacheKey string) (*CachedFile, CachingInfoType, error)

func (*FileCache) Remove

func (c *FileCache) Remove(cacheKey string)

Directories

Path Synopsis
This file was generated by counterfeiter
This file was generated by counterfeiter

Jump to

Keyboard shortcuts

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