originstorage

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReadOnly = errors.New("Read-only torrent is being written to")
)

Torrent errors.

Functions

This section is empty.

Types

type Torrent

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

Torrent is a read-only storage.Torrent. It allows concurrent reads on all pieces.

func NewTorrent

func NewTorrent(cas *store.CAStore, mi *core.MetaInfo) (*Torrent, error)

NewTorrent creates a new Torrent.

func (*Torrent) Bitfield

func (t *Torrent) Bitfield() *bitset.BitSet

Bitfield always returns a completed bitfield.

func (*Torrent) BytesDownloaded

func (t *Torrent) BytesDownloaded() int64

BytesDownloaded always returns the total number of bytes.

func (*Torrent) Complete

func (t *Torrent) Complete() bool

Complete is always true.

func (*Torrent) Digest

func (t *Torrent) Digest() core.Digest

Digest returns the digest of the target blob.

func (*Torrent) GetPieceReader

func (t *Torrent) GetPieceReader(pi int) (storage.PieceReader, error)

GetPieceReader returns a reader for piece pi.

func (*Torrent) HasPiece

func (t *Torrent) HasPiece(pi int) bool

HasPiece returns if piece pi is complete. For Torrent it's always true.

func (*Torrent) InfoHash

func (t *Torrent) InfoHash() core.InfoHash

InfoHash returns the torrent metainfo hash.

func (*Torrent) Length

func (t *Torrent) Length() int64

Length returns the length of the target file.

func (*Torrent) MaxPieceLength

func (t *Torrent) MaxPieceLength() int64

MaxPieceLength returns the longest piece length of the torrent.

func (*Torrent) MissingPieces

func (t *Torrent) MissingPieces() []int

MissingPieces always returns empty list.

func (*Torrent) NumPieces

func (t *Torrent) NumPieces() int

NumPieces returns the number of pieces in the torrent.

func (*Torrent) PieceLength

func (t *Torrent) PieceLength(pi int) int64

PieceLength returns the length of piece pi.

func (*Torrent) Stat

func (t *Torrent) Stat() *storage.TorrentInfo

Stat returns the TorrentInfo for t.

func (*Torrent) String

func (t *Torrent) String() string

func (*Torrent) WritePiece

func (t *Torrent) WritePiece(src storage.PieceReader, pi int) error

WritePiece returns error, since Torrent is read-only.

type TorrentArchive

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

TorrentArchive is a TorrentArchive for origin peers. It assumes that all files (including metainfo) are already downloaded and in the cache directory.

func NewTorrentArchive

func NewTorrentArchive(
	cas *store.CAStore, blobRefresher *blobrefresh.Refresher) *TorrentArchive

NewTorrentArchive creates a new TorrentArchive.

func (*TorrentArchive) CreateTorrent

func (a *TorrentArchive) CreateTorrent(namespace string, d core.Digest) (storage.Torrent, error)

CreateTorrent is not supported.

func (*TorrentArchive) DeleteTorrent

func (a *TorrentArchive) DeleteTorrent(d core.Digest) error

DeleteTorrent moves a torrent to the trash.

func (*TorrentArchive) GetTorrent

func (a *TorrentArchive) GetTorrent(namespace string, d core.Digest) (storage.Torrent, error)

GetTorrent returns a Torrent for an existing file on disk. If the file does not exist, attempts to re-fetch the file from the storae backend configured for namespace in a background goroutine, and returns os.ErrNotExist.

func (*TorrentArchive) Stat

func (a *TorrentArchive) Stat(namespace string, d core.Digest) (*storage.TorrentInfo, error)

Stat returns TorrentInfo for given digest. If the file does not exist, attempts to re-fetch the file from the storae backend configured for namespace in a background goroutine.

Jump to

Keyboard shortcuts

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