zipred

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2018 License: LGPL-3.0 Imports: 7 Imported by: 0

README

zipred

Build Status GoDoc Go Report Card Codacy Badge

ZIP file operations can get costly, especially for large files. This library allows you to filter and extract an online zip file on the fly.

In contrast to a conventional zip parser, it has the following benefits:

  • There is less latency since data is processed directly from the buffer on the fly.
  • The download can be stopped once the metadata or target file has been found. Hence, less data is transferred.
  • Irrelevant data is directly discarded without memory allocation.

This library gives you an efficient and idiomatic way for indexing zip files on the web.

For examples, check the corresponding folder.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterFileInfo

func FilterFileInfo(z Zipred) (keys []string, err error)

FilterFileInfo filters the given URL's zip file and returns all file names on which the given predicate applies.

func FilterZipContent

func FilterZipContent(z Zipred) (files map[string][]byte, err error)

FilterZipContent filters the given URL's zip file and returns all file contents on which the given predicate applies.

func UseLogger

func UseLogger(logger *onelog.Logger)

UseLogger sets a custom Logger for the package.

Types

type Zipred

type Zipred interface {
	// URL to download the archive from
	URL() string
	// Predicate indicates if the given file should be read or not.
	// It is to return a zero string to discard the file, otherwise the key name.
	// If error is nonempty, the download is aborted and the error is passed on.
	Predicate(fileInfo os.FileInfo) (key string, err error)
	// Done indicates if enough data has been read and the download can be aborted ahead of the EOF.
	// isEOF is true if the end of the zip file has been reached.
	// If error is nonempty, the download is aborted and the error is passed on.
	Done(isEOF bool) (finish bool, err error)
}

Zipred allows the implementation of a context that dynamically defines the boundaries of the zip filtering.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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