]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Allows one to use Custom PieceCompletion (#486) v1.27.0
authorgitpubber <76197622+gitpubber@users.noreply.github.com>
Sun, 9 May 2021 09:34:41 +0000 (15:04 +0530)
committerGitHub <noreply@github.com>
Sun, 9 May 2021 09:34:41 +0000 (19:34 +1000)
* Change ClientImpl to ClientImplCloser

We cannot close underlying Boltdb PieceCompletion if it is not closable

* Update file.go

storage/file.go

index a4c2901577b5a3baed02c4760862f13381657d41..1a273a345f019df6fbdd213aea425c70c09eba77 100644 (file)
@@ -36,7 +36,7 @@ func NewFile(baseDir string) ClientImplCloser {
 }
 
 func NewFileWithCompletion(baseDir string, completion PieceCompletion) *fileClientImpl {
-       return newFileWithCustomPathMakerAndCompletion(baseDir, nil, completion)
+       return NewFileWithCustomPathMakerAndCompletion(baseDir, nil, completion)
 }
 
 // File storage with data partitioned by infohash.
@@ -48,10 +48,11 @@ func NewFileByInfoHash(baseDir string) ClientImplCloser {
 // responsible for sanitizing the info if it uses some part of it (for example sanitizing
 // info.Name).
 func NewFileWithCustomPathMaker(baseDir string, pathMaker func(baseDir string, info *metainfo.Info, infoHash metainfo.Hash) string) ClientImplCloser {
-       return newFileWithCustomPathMakerAndCompletion(baseDir, pathMaker, pieceCompletionForDir(baseDir))
+       return NewFileWithCustomPathMakerAndCompletion(baseDir, pathMaker, pieceCompletionForDir(baseDir))
 }
 
-func newFileWithCustomPathMakerAndCompletion(baseDir string, pathMaker func(baseDir string, info *metainfo.Info, infoHash metainfo.Hash) string, completion PieceCompletion) *fileClientImpl {
+// Allows passing custom PieceCompletion 
+func NewFileWithCustomPathMakerAndCompletion(baseDir string, pathMaker func(baseDir string, info *metainfo.Info, infoHash metainfo.Hash) string, completion PieceCompletion) *fileClientImpl {
        if pathMaker == nil {
                pathMaker = defaultPathMaker
        }