]> Sergey Matveev's repositories - btrtrc.git/blob - storage/file-deprecated.go
Drop support for go 1.20
[btrtrc.git] / storage / file-deprecated.go
1 package storage
2
3 import (
4         "github.com/anacrolix/torrent/metainfo"
5 )
6
7 func NewFileWithCompletion(baseDir string, completion PieceCompletion) ClientImplCloser {
8         return NewFileWithCustomPathMakerAndCompletion(baseDir, nil, completion)
9 }
10
11 // File storage with data partitioned by infohash.
12 func NewFileByInfoHash(baseDir string) ClientImplCloser {
13         return NewFileWithCustomPathMaker(baseDir, infoHashPathMaker)
14 }
15
16 // Deprecated: Allows passing a function to determine the path for storing torrent data. The
17 // function is responsible for sanitizing the info if it uses some part of it (for example
18 // sanitizing info.Name).
19 func NewFileWithCustomPathMaker(baseDir string, pathMaker func(baseDir string, info *metainfo.Info, infoHash metainfo.Hash) string) ClientImplCloser {
20         return NewFileWithCustomPathMakerAndCompletion(baseDir, pathMaker, pieceCompletionForDir(baseDir))
21 }
22
23 // Deprecated: Allows passing custom PieceCompletion
24 func NewFileWithCustomPathMakerAndCompletion(
25         baseDir string,
26         pathMaker TorrentDirFilePathMaker,
27         completion PieceCompletion,
28 ) ClientImplCloser {
29         return NewFileOpts(NewFileClientOpts{
30                 ClientBaseDir:   baseDir,
31                 TorrentDirMaker: pathMaker,
32                 PieceCompletion: completion,
33         })
34 }