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 ¶
- func Paths(base string, info *metainfo.Info) ([]string, error)
- type Storage
- func (s *Storage) BlockFiles(ih metainfo.Hash, paths []string) (unblock func())
- func (s *Storage) CloseFiles(ih metainfo.Hash, paths []string)
- func (s *Storage) OpenTorrent(_ context.Context, info *metainfo.Info, ih metainfo.Hash) (storage.TorrentImpl, error)
- func (s *Storage) Trust(ih metainfo.Hash)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
NewResolver creates a storage whose directory is decided per torrent.
func (*Storage) BlockFiles ¶
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 ¶
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.