file-deprecated.go 1.2 KB

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