bagit

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: MIT Imports: 20 Imported by: 0

README

bagit

bagit is a library and command line tool to work with the BagIt format

Wikipedia: https://en.wikipedia.org/wiki/BagIt

IETF: https://tools.ietf.org/html/rfc8493

Build Status

Version: 0.2.0

Usage examples

Create a simple bag:

gobagit -create testinputdir

Create a bag with some possible commandline options

gobagit -create testinputdir -output outbagdir -tar -hash sha1 -header headerfile.json

Create a bag with all possible commandline options

gobagit -create testinputdir -output outbagdir -tar -hash sha1 -header headerfile.json -fetch fetch.txt -manifetch fetchmanifest.txt

Validate a bag

gobagit -validate bagdir/

Pass additional headers as a json file, no nesting supported. Example:

{
    "Source-Organization": "FOO University",
    "Contact-Email":"steffen@fritz.wtf"
}

Commandline options:

-create PATH_TO_DIR
    Create bag. Expects path to source directory
-fetch string
    Adds optional fetch file to bag. Expects path to fetch.txt file and switch manifetch
-hash ALGORITHM
    Hash algorithm used for manifest file when creating a bag [sha1, sha256, sha512, md5] (default "sha512")
-header PATH_TO_FILE
    Additional headers for bag-info.txt. Expects path to json file
-manifetch string
    Path to manifest file for optional fetch.txt file. Mandatory if fetch switch is used
-output PATH_TO_DIR
    Output directory for bag. Used with create flag (default "bag_2019-06-11T225839")
-tar
    Create a tar archive when creating a bag
-v    Verbose output
-validate PATH_TO_BAG
    Validate bag. Expects path to bag
-version
    Print version

Installation

From source

go get github.com/steffenfritz/bagit/cmd/gobagit

Binary

Download a pre-built binary from the releases page.

Limitations

  1. Only one payload manifest file is supported in version 0.2.0
  2. No additional tag directories are supported in version 0.2.0
  3. Issues page https://github.com/steffenfritz/bagit/issues
  4. When creating a bag fetch does NOT validate if the provided hashes match the hash algorithm for the bag's manifest

Documentation

Index

Constants

View Source
const (
	// BagitVer is the version of the bagit spec this library coresponds to
	BagitVer = "1.0"
	// TagFileCharEnc is the encoding of the tag files
	TagFileCharEnc = "UTF-8"
)

Variables

This section is empty.

Functions

func ValidateFetchFile added in v0.2.0

func ValidateFetchFile(inFetch string) (bool, bool, int, int)

ValidateFetchFile validates fetch.txt files for correct syntax and returns sum of length and file count

Types

type Bagit

type Bagit struct {
	Timestamp     string
	Hashfunc      crypto.Hash
	Bagname       string
	Oxum          Oxum
	SrcDir        *string
	OutDir        *string
	HashAlg       *string
	FetchFile     *string
	FetchManifest *string
	AddHeader     *string
}

Bagit is a struct that describes a bag

func New

func New() *Bagit

New creates a new Bagit struct

func (*Bagit) Create

func (b *Bagit) Create(verbose bool) error

Create creates a new bagit archive

func (*Bagit) Tarit

func (b *Bagit) Tarit(srcDir string, outFile string) error

Tarit tars a directory

func (*Bagit) Validate

func (b *Bagit) Validate(srcDir string, verbose bool) error

Validate validates a bag for completeness and correctness

type Oxum

type Oxum struct {
	Bytes     int64
	Filecount int
}

Oxum defnies a type that holds the sum of all bytes and files in the data dir

Directories

Path Synopsis
cmd
gobagit command

Jump to

Keyboard shortcuts

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