store

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store is the torrent file storage. It replaces the engine's default storage, which memory-maps files and keeps them mapped until shutdown: on Windows that makes it impossible to delete or move a downloaded file while the daemon runs. Here every file is opened on demand, cached briefly and closed when idle or when the torrent is dropped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Paths

func Paths(base string, info *metainfo.Info) ([]string, error)

Paths returns the on-disk location of every file of the torrent, in torrent order.

Types

type Storage

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

Storage implements storage.ClientImpl. Files live at <base>/<torrent name>/<path>, where base is chosen per torrent.

func New

func New(base string, comp storage.PieceCompletion) *Storage

New creates a storage that keeps every torrent under one directory; comp remembers which pieces are verified (may be nil).

func NewResolver

func NewResolver(baseFor func(metainfo.Hash) string, comp storage.PieceCompletion) *Storage

NewResolver creates a storage whose directory is decided per torrent.

func (*Storage) BlockFiles

func (s *Storage) BlockFiles(ih metainfo.Hash, paths []string) (unblock func())

BlockFiles makes the given files of a torrent unreachable for the engine until the returned function is called: reads fail as if the file was missing and writes are dropped, and the open handles are closed as soon as nobody uses them. It is how a file is deleted while the torrent is being checked or is downloading: without it the engine opens the file again at once and the deletion fails with "used by another process".

func (*Storage) CloseFiles

func (s *Storage) CloseFiles(ih metainfo.Hash, paths []string)

CloseFiles closes the open handles of the given files of a torrent (a handle that is in use goes on the moment it is free), so that the files can be deleted or moved at once instead of after the idle timeout.

func (*Storage) OpenTorrent

func (s *Storage) OpenTorrent(_ context.Context, info *metainfo.Info, ih metainfo.Hash) (storage.TorrentImpl, error)

func (*Storage) Trust

func (s *Storage) Trust(ih metainfo.Hash)

Trust makes the next opening of the torrent take the files that are already on disk, at full size, as finished without hashing them ("skip the hash check"). It applies once.

Jump to

Keyboard shortcuts

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